ArcBasicDocs
2DBasicArcBasic extension

IIf

Gives back one of two values, chosen by a condition.

IIf ( condition,if_true,if_false )

Parameters

condition
what to check; any number other than 0 counts as true.
if_true
what to give back when the condition is true.
if_false
what to give back when it is false.

Description

Gives back one of two values, chosen by a condition: the first when it is true, the second when it is false. Only the chosen one is worked out, so the other can be something that would fail, such as dividing by a number that is 0. If one value is text, the result is text; if one is a decimal number, the result is a decimal number.

Example

IIf.abs
label$ = IIf(lives = 1, "life", "lives")speed# = IIf(KeyDown(KEY_LSHIFT), 8, 4)

See also