Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Function Declaration
-
Function Switch(ParamArray VarExpr() As Variant) As Variant
|
Parameter |
Description |
|---|---|
|
VarExpr |
Array of type Variant containing expressions to be evaluated. |
Runtime Semantics.
Evaluates a list of expressions and returns a Variant value or an expression associated with the first expression in the list that evaluates to the data value True.
The Switch function argument list consists of pairs of expressions and values. The expressions are evaluated from left to right, and the value associated with the first expression to evaluate to True is returned. If the parts aren't properly paired, a run-time error occurs. For example, if VarExpr(0) evaluates to the data value True, Switch returns VarExpr(1). If VarExpr(0) evaluates to the data value False, but VarExpr(2) evaluates to the data value True, Switch returns VarExpr(3), and so on.
Switch returns a Null value if:
None of the expressions evaluates to the data value True.
The first True expression has a corresponding value that is the data value Null.
Switch evaluates all of the expressions, even though it returns only one of them. For example, if the evaluation of any expression results in a division by zero error, an error occurs.