You can use the single-line form (1st syntax) for short, simple tests. However, the block form (2nd syntax) provides more structure and flexibility than the single-line form and is usually easier to read, maintain, and debug.
Tip: The single-row form allows to enter multiple statements, but each of the statements must be separated by "colon" character:
If A > 10 Then A = A + 1 : B = B + A : C = C + B
When executing a block
If (2nd syntax), condition is tested. If condition is
true, then the statements following
Then are executed. If condition is
false, then each
ElseIf (if any) is evaluated in turn. If a
true condition is found, then the statements following the associated
Then are executed. If none of the
ElseIf statements are
true (or there are no
ElseIf clauses), then the statements following
Else are executed. After executing the statements following
Then or
Else, execution continues with the statement following
End If.
The
Else and
ElseIf clauses are both optional. You can have as many
ElseIf statements as you want in a block
If, but none can appear after the
Else clause. Block
If statements can be nested; i.e. can be contained within one another.
What follows the
Then keyword is examined to determine whether or not a statement is a block
If. If anything other than a comment appears after
Then on the same line, the statement is treated as a single-line
If statement.
A block
If statement must be the first statement on a line. The block
If must end with an
End If statement.
In the JavaScript language is used the statement for this purpose
if...else.