The block form of If...Then...Else provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug.
In executing a block If, the map tests condition1, the first numeric expression. If the expression is true, the statements following Then are executed. If the first expression is false, the map begins evaluating each ElseIf condition in turn. When the map finds a true condition, the statements following the corresponding Then are executed. If none of the ElseIf conditions is true, the statements following Else are executed. After executing the statements following Then or Else, the program continues with the statement following End If.
The Else and ElseIf blocks are both optional. You can have as many ElseIf clauses as you like in a block If, but none can appear after an Else clause. Any of the statement blocks can contain nested block If statements.
The map looks at what appears after the Then reserved word to determine whether or not an If statement is a block If. If anything other than a comment appears after Then, the statement is treated as a single-line If statement.
A block If statement must be the first statement on a line. The Else, ElseIf, and End If parts of the statement can have only a line number or line label in front of them. The block must end with an End If statement.
Use the If Then Else statement to define two blocks of statements. One of the statements runs when the specified condition is True, and the other one runs when the condition is False. When you want to define more than two blocks of statements, use the ElseIf Statement.
You can nest up to ten levels of If... Then... Else statements. If you need to create an expression with more than ten levels, you must redefine it using the ElseIf statement or the Select Case...End Case Statement.