Home / lang / iif 
IIf
Syntax
Value = IIf ( bTest AS Boolean , vTrue , vFalse )
Value = If ( bTest AS Boolean , vTrue , vFalse )

Evaluate the bTest expression, and return vTrue if this expression is TRUE, or vFalse if this expression is FALSE.

Be careful! Contrary to IF, or the C/Perl ? operator, both vTrue and vFalse are evaluated, whatever the value of bTest is.

Examples

X = 7
PRINT If((X MOD 2) = 0, "even", "odd")

odd
' Never do the following in real code, because it is not translatable!
X = 7
PRINT "You have " & X & " message" & If(X <> 1, "s", "") & " waiting."

You have 7 messages waiting.
PRINT If((X MOD 2) = 1, "odd", 1 / 0)

Division by zero

See also

Test Control Structures & Functions