Use the If...Then statement to run one or more statements when a specified condition is True. You can use either a single-line syntax or a multiple-line "block" syntax; the following pair of examples illustrates both of these types of syntax.
If thisVal < 0 Then thisVal = 0 If thisVal > 5 Then thatVal = thisVal + 25 thisVal = 0 End If
Notice that the single-line form of the If...Then statement doesn't use an End If statement. If you want to run more than one line of code when the condition is True, you must use the multiple-line If...Then...End If syntax.
Note
When the condition you're evaluating contains two expressions joined by an Or operator — for example, If (thisVal > 5 Or thatVal < 9) — both expressions are tested, even if the first one is True. In rare circumstances, this behavior can affect the outcome of the statement; for example, it can cause a run-time error if a variable in the second expression contains an error value.