條件陳述式格式參考

If-Then-Else 格式

If <conditional expression> Then
<one or more statements to be executed if condition is true>
Else
<one or more statements to be executed if condition is false>
End If

If-Then 格式

If <conditional expression> Then
<one or more statements to be executed if condition is true>
End If

Null 格式

If <conditional expression> Then ‘do nothing
Else <one or more statements to be executed if condition is false>
End If

將 If 陳述式做為單行

If <conditional expression> Then <true statement> [Else <false statement>]

延伸區塊 If (If-Then-ElseIf) 格式

If <conditional expression 1> Then
<one or more statements to be executed if condition 1 is true>
ElseIf <conditional expression 2> Then
<one or more statements to be executed if condition 2 is true>
...
ElseIf <conditional expression n> Then
<one or more statements to be executed if condition n is true>
Else
<one or more statements to be executed if none of the above conditions is true>
End If

Select Case 格式

Select Case <test expression>
Case <expression list 1>
<statement list 1>
Case <expression list 2>
<statement list 2>
Case Else
<statement list n>
End Select