param definition

[ [Optional] [ | ByVal | ByRef ] | ParamArray ]
param[type][( )] [As type]
[ = defaultvalue ]

The param receives the value of the associated expression in the Declare, Sub, Function, or Property call. (See arglist.)

  • An Optional param can be omitted from the call. It can also have a defaultvalue. The parameter receives the defaultvalue if a value is not specified by the call. If the defaultvalue is omitted, the parameter is a Variant and no value is specified in the call then IsMissing returns True.
  • All parameters following an Optional parameter must also be Optional.
  • ParamArray can be used on the final param. It must be an array of Variant type. It must not follow any Optional parameters. The ParamArray receives all the expressions at the end of the call as an array. If LBound(param) > UBound(param), the ParamArray did not receive any expressions.
  • If the param is not ByVal and the expression is merely a variable then the param is a reference to that variable (ByRef). (Changing param changes the variable.) Otherwise, the parameter variable is local to the procedure, so changing its value does not affect the caller.
  • Use param( ) to specify an array parameter. An array parameter must be referenced and can not be passed by value. The bounds of the parameter array are available using LBound( ) and UBound( ).