Funktionen

# Funktionen IIf

Returnerer et af to mulige resultater, afhĂ¦ngigt af den logiske vĂ¦rdi af det validerede udtryk.

### Syntaks:

``````
IIf (Bool As Boolean, Variant1 As Variant, Variant2 As Variant) As Variant
``````

### Parametre:

Bool: Any expression that you want to evaluate. If the expression evaluates to True, the function returns the value of Variant1, otherwise it returns the value of Variant2.

Variant1, Variant2: Any expression, one of which will be returned as the function result, depending on the logical evaluation.

IIf evaluates both Variant1 and Variant2 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.

### Fejlkoder:

5 Ugyldigt Procedurekald

### Eksempel:

``````
REM Returnerer den hĂ¸jeste af 3 vĂ¦rdier
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 DĂĄrlig anvendelse af funktionen IIf
Function Inverse(A As Double) As Double
Inverse = IIf( A = 0, 0, 1/A )
End Function
``````

ErklĂ¦ringerne If eller Select Case

Funktionen Switch

StĂ¸t os venligst!