IIf
Value = IIf ( Test AS Boolean , TrueExpression , FalseExpression )
Value = If ( Test AS Boolean , TrueExpression , FalseExpression )
Evaluate the
Test expression, and return
TrueExpression if this expression is
TRUE,
or
FalseExpression if this expression is
FALSE.
 |
BE CAREFUL!
Contrary to IF, or the C/Perl ? operator, both TrueExpression and FalseExpression are evaluated, whatever the value of Test is.
|
Beispiel
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