return value from user-defined function : Function Return « Language Basics « VBA / Excel / Access / Word






return value from user-defined function

 
Function Tax(ProfitBeforeTax As Double) As Double
  If ProfitBeforeTax > 0 Then Tax = 0.3 * ProfitBeforeTax Else Tax = 0
End Function



Sub test()
    MsgBox Tax(100)
End Sub

 








Related examples in the same category

1.Specifying the Data Type for a Function's Result
2.Return number from function
3.Passing Parameters and Returning Values
4.Return a string from funtion
5.Functions That Return an Array
6.Returning a sorted list