VBScript Tutorials - Herong's Tutorial Examples - Version 5.23, by Dr. Herong Yang
This section describes 4 forms of 'If' statements supported in VBScript. The more complex form is 'If ... ElseIf ... Else ... End If'.
There are 4 forms of "If" statements supported in VBScript:
1. Single-statement "If":
If condition Then statement
where "condition" is Boolean value, and "statement" specify another statement. The specified statement will be executed, if and only if the specified condition is evaluated to "True".
2. Multi-statement "If":
If condition Then statement_block (multiple statements) End If
The specified multi-statement block will be executed, if and only if the specified condition is evaluated to "True".
3. "If ... Else" Statement:
If condition Then statement_block_a Else statement_block_b End If
Two statement blocks are specified. But only one statement block will be executed based on the value of the specified condition. If the specified condition is "True", the first block will be executed. If the specified condition is "False", the second block will be executed.
4. "If ... ElseIf" Statement:
If condition_1 Then statement_block_1 ElseIf condition_2 Then statement_block_2 ... ... Else statement_block_n End If
Many statement blocks are specified. But only one statement block will be executed based on the value of the condition specified for that block.
Table of Contents