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.
Note With the single-line syntax, it is possible to have multiple statements executed as the result of an If...Then decision, but they must all be on the same line and separated by semicolon, as in the following statement:
if (a>10) {a=1; b=5; c=0;}
When executing a block (2nd syntax), the condition is tested.
If the condition is
true, then the following statements are executed.
If the condition is
false, then the
else if blocks (if present) are evaluated.
If the
true condition is found, then the following corresponding statements are executed.
If none of the
else if conditions is evaluated as
true (or there is no
else if block present), then the statements that follow after
else are executed.
The
else and
else if blocks are both optional. You can have as many
else if statements as you want in a block
if, but none can appear after the
else clause. The
if statements can be nested, i.e. can be contained in another
if statements.
It is also possible to use the single-line form of conditional assignment of the value to a single variable.
If condition is evaluated as
true, then the value written after the question mark is assigned. Otherwise the value written after the colon is assigned.
In the VBScript language is used the statement for this purpose
If...Then...Else.