Use IIF to calculate value : IIF « Language Basics « VBA / Excel / Access / Word






Use IIF to calculate value

 

Function Tax(ProfitBeforeTax As Double) As Double
  Tax = IIf(ProfitBeforeTax > 0, 0.3 * ProfitBeforeTax, 0)
End Function

Sub test()
    MsgBox Tax(100)
End Sub

 








Related examples in the same category

1.The Immediate If (IIf)
2.Use IIF(conditional test, value for True, value for False)
3.Choosing an Action Using IIf(expr, truepart, falsepart)