Syntax
The syntax of the IIf function is as follows:
IIf(expr, truepart, falsepart)All three parameters are required:
- expr is the expression that is to be evaluated.
- truepart defines what the IIf function returns if the evaluation of expr returns true.
- falsepart defines what the IIf function returns if the evaluation of expr returns false.
Many languages have an operator to accomplish the same purpose, generally referred to as a conditional operator (or, less accurately, as a ternary operator); the best known is ?:, as used in C, C++, and related languages. Some of the problems with the IIf function, as discussed later, do not exist with a conditional operator, because the language is free to examine the type and delay evaluation of the operands, as opposed to simply passing them to a library function.
Read more about this topic: IIF