Collabora Office 21.06 Help
依據所演算表示式的邏輯值,傳回兩個可能的函式結果之一。
IIf (Expression, ExpressionTrue, ExpressionFalse)
Expression:要演算的任意表示式。如果表示式的演算值為 True (真),函式將傳回 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.
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