Syntax |
Switch(condition1,expression1 [,condition2,expression2 ... [,condition7,expression7]]) |
Description |
Returns the expression corresponding to the first True condition. |
Comments |
The Switch function evaluates each condition and expression, returning the expression that corresponds to the first condition (starting from the left) that evaluates to True. Up to seven condition/expression pairs can be specified. A runtime error is generated it there is an odd number of parameters (that is, there is a condition without a corresponding expression). The Switch function returns Null if no condition evaluates to True. |
Example |
The following code fragment displays the current operating platform. If the platform is unknown, then the word "Unknown" is displayed. Sub Main() |
See Also |
Choose (function); IIf (function); If...Then...Else (statement); Select...Case (statement). |
S |