IIf Function

Hesaplanan ifadenin mantıksal değerine bağlı olarak olası iki fonksiyon sonucundan birini döndürür.

Sözdizimi:


IIf (İfade, Doğruİfade, Yanlışİfade)

Parametreler:

İfade: Hesaplamak istediğiniz herhangi bir ifade. Eğer ifade True değerini hesaplarsa, fonksiyon Doğruİfade değerini, değilse Yanlışİfade değerini döndürür.

Doğruİfade, Yanlışİfade: Fonksiyona bağlı olarak sadece biri döndürülecek herhangi iki fiade.

note

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.


Hata kodları:

5 Geçersiz yordam çağrısı

Örnek:


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

Lütfen bizi destekleyin!