0% found this document useful (0 votes)
77 views2 pages

If Statement

The document discusses the syntax and usage of If-Else and If-ElseIf-Else statements in VB.Net. An If statement can optionally be followed by an Else statement to execute code if the Boolean expression is false. An If statement can also be followed by multiple ElseIf statements and a single Else statement to test various conditions using a single statement. The ElseIf and Else blocks are only executed if all previous conditions are false.

Uploaded by

Jt Evia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views2 pages

If Statement

The document discusses the syntax and usage of If-Else and If-ElseIf-Else statements in VB.Net. An If statement can optionally be followed by an Else statement to execute code if the Boolean expression is false. An If statement can also be followed by multiple ElseIf statements and a single Else statement to test various conditions using a single statement. The ElseIf and Else blocks are only executed if all previous conditions are false.

Uploaded by

Jt Evia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

An If statement can be followed by an optional Else statement, which

executes when the Boolean expression is false.

Syntax:
The syntax of an If...Then... Else statement in VB.Net is as follows:
If(boolean_expression)Then
'statement(s) will execute if the Boolean expression is true
Else
'statement(s) will execute if the Boolean expression is false
End If

If the Boolean expression evaluates to true, then the if block of code will be
executed, otherwise else block of code will be executed.

The If...Else If...Else Statement


An If statement can be followed by an optional Else if...Else statement,
which is very useful to test various conditions using single If...Else If
statement.
When using If... Else If... Else statements, there are few points to keep in
mind.

An If can have zero or one Else's and it must come after an Else If's.

An If can have zero to many Else If's and they must come before the Else.

Once an Else if succeeds, none of the remaining Else If's or Else's will be tested.

Syntax:
The syntax of an if...else if...else statement in VB.Net is as follows:
If(boolean_expression 1)Then
' Executes when the boolean expression 1 is true
ElseIf( boolean_expression 2)Then

' Executes when the boolean expression 2 is true


ElseIf( boolean_expression 3)Then
' Executes when the boolean expression 3 is true
Else
' executes when the none of the above condition is true
End If

You might also like