Use IIF(conditional test, value for True, value for False) : IIF « Language Basics « VBA / Excel / Access / Word






Use IIF(conditional test, value for True, value for False)

 

Sub IIFSub()
    Dim strMessage As String
    Dim intNum As Integer
    
    intNum = 12
    
    strMessage = IIf(intNum > 10, "Number is greater than 10", "Number is less than 10")
    
    Debug.Print strMessage
    
End Sub

 








Related examples in the same category

1.The Immediate If (IIf)
2.Use IIF to calculate value
3.Choosing an Action Using IIf(expr, truepart, falsepart)