# IIf Function

αααα‘ααββααααααββα’αα»ααααββαααβα’αΆαβααβαβα’αΆαβααΎαβα‘αΎαββαα½αβααα’αα»ααααββααΈα α’αΆαααααβααΎβαααααβααααβαα·ααααΆβααβααααααβαααβααΆαβααΆαβαααααΒ α

### Syntax:

``````
IIf (Expression, ExpressionTrue, ExpressionFalse)
``````

### Parameters:

Expression α αααααααα½αβαααα½αβ αααβα’αααβαααβααΆαβαααααΒ α ααααα·αβααΎβαααααα αα·α α’αα»ααααβαααα‘ααβαααααα ExpressionTrue ααΎβαα»αβαααααββααΆβαααα‘ααβαααααα ExpressionFalseΒ α

ExpressionTrue, ExpressionFalse α ααααααββαα½αβαααα½αβ αααβααααααβαα½αβαααα»αβαααααβααΆααα’ααβααΉαβααααΌαβααΆαβαααα‘ααβααΆβααααααβα’αα»αααα α’αΆαααααβααΎβααΆαβααΆαβαααααβααααβαα·ααααΆΒ α

IIf evaluates both ExpressionTrue and ExpressionFalse even if it returns only one of them. If one of the expressions results in error, the function returns the error. For example, do not use IIF to bypass a possible division by zero result.

### Error codes:

5 ααΆαβα αβαααααβαα·αβααααΉαααααΌα

### Example:

``````
REM Returns the maximum of 3 values
Function Max (A As Double, B As Double, C, As Double) As Double
Max = IIf( A >= B, A, B)
Max = IIf( C >= Max, C, Max)
End Function
REM Bad usage of function IIf
Function Inverse(A As Double) As Double
Inverse = IIf( A = 0, 0, 1/A )
End Function
``````

If or Select Case statements

Switch function