This is a compound multi line statement designed to allow conditional execution of other statements. There is also an abbreviated single line version.
Syntax
If expression1 Then
statements1
[ElseIf expression2 Then
statements2]
[Else
statements3]
End If
The statements sections can contain a number of statements. A number of ElseIf blocks can be included. There can be only one Else block and this must follow after all ElseIf blocks. The statement performs as follows:
Expression1 is evaluated. If it is True, statements1 are executed. If it is False, expression2 is evaluated. If it is True, statements2 are executed. The statements in the Else block are only executed if all the previous evaluated expressions are False. An expression that is null is treated as False.
The If, ElseIf, Else and End If statements must be the only statements on the line.
Single Line Syntax
If condition Then statements [Else statements]