Function Definition

Syntax:

[ | Private | Public | Friend ] [ Default ] Function name[type][([param[, ...]])] [As type[()]]

statements

End Function

Group: Declaration

Description:
User defined function. The function defines a set of statements to be executed when it is called. The values of the calling arglist are assigned to the params. Assigning to name[type] sets the value of the function result.

Function defaults to Public if Private, Public or Friend are not is specified.

See Also: Declare, Property, Sub.

Example:

Function Power(X,Y)
  P = 1
  For I = 1 To Y
  P = P*X
  Next I
  Power = P
End
Function

Sub Main
  Debug.Print Power(2,8) ' 256
End
Sub