Returns one of two values, depending on the result of the specified expression.
IIf (expr, truepart, falsepart)
Expr - (Input, expression, Required)
Specifies the expression to evaluate. The result of this expression is converted to a Boolean value (True or False). A non-zero result is considered as True. If expr evaluates to a string expression, it is converted to numeric form first. If the resulting expr value is non-numeric, or if expr is Error, neither expression is returned and the result is Error.
Truepart - (Input, expression, Required)
Specifies the expression whose result is returned if expr is not False.
Falsepart - (Input, expression, Required)
Specifies the expression whose result is returned if expr is False.
The value of Truepart or Falsepart, depending on the value of expr. Error is returned if expr is Error.
Both truepart and falsepart are evaluated, even though only one of them is returned. This can become important if the expressions have unexpected side effects.
IIf ( 1 < 2, “Right”, “Wrong”) |
Returns “Right” |
IIf ( 1 > 2, “Right”, “Wrong”) |
Returns “Wrong” |
IIf (4.5, “Non-zero”, “Zero”) |
Returns “Non-zero” |
IIf (“abc”, “Non-zero”, “Zero”) |
Returns “Zero” |
IIf (Null, 1, 0) |
Returns Error |
IIf (Error, 1, 0) |
Returns Error |
Functions are specifically for use in the Macro Editor. Refer to Microsoft's official VB and JScript documentation for scripting equivalents.
Functions | Choose function | Description function | Iff function | In function | Lookup function | Switch function | Value function
© 2004-2021 looksoftware. All rights reserved.