Specifying the Data Type for a Function's Return Value

If you want to restrict the return value of a Function procedure to a particular data type, declare the return value's type using the As keyword after the parentheses that follow the function name.


Function CalcPay(hours, rate) As Currency

In the absence of an As clause, the return value will have the Variant type by default.

Note

You can also use the As keyword within the parentheses enclosing the argument list to specify the data types of procedure arguments, as in this example: Function CalcPay(hours As Integer, rate As Currency) As Currency. For more information, see "Specifying Argument Data Types" later in this chapter.