## Function Statement

Function Fname [(Arguments)] [As type]

[statements]

Functionname = expression

[statements]

Functionname = expression

End Function

Declares and defines a procedure that can receive arguments and return a value of a specified data type.

When the optional argument list needs to be passed the format is as follows:

([ByVal] variable [As type] [,ByVal] variable [As type] ]…])

The optional ByVal parameter specifies that the variable is [passed by value instead of by reference (see “ByRef and ByVal” in this manual). The optional As type parameter is used to specify the data type. Valid types are String, Integer, Double, Long, and Varaint (see “Variable Types” in this manual).

Related Topics: Dim, End, Exit, Sub

More:

Example: