If

From Xojo Documentation

Operator

A trinary operator that evaluates an expression and returns results when it is True or False.

Usage

If(condition, <result when expression is true>, <result when expression is false>)

Part Description
condition Required. A boolean, numeric, or string expression that evaluates to True or False.
result when expression is true Required. This result is returned when the expression evaluates to True.
result when expression is false Required. This result is returned when the expression evaluates to False.

Notes

The return type is the common type between the two result values. For example, if an Int8 and an Int32 are used as result values, the result type will actually be Int32. Having no common type results in a Type Mismatch compile error.

This operator uses the same evaluation rules as a normal If..Then statement. Only the result that is needed gets evaluated.

Sample Code

This code outputs "Big number":

Dim myInteger As Integer = 42
MsgBox(If(myInteger > 40, "Big number", "Small number"))

See Also

If...Then...Else