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 may be omitted from the call. It may also have a defaultvalue. The parameter receives the default value if a value is not specified by the call. If the default value is omitted, the parameter is a Variant and no value is specified in the call then IsMissing will return True.
  • All parameters following an Optional parameter must also be Optional.
  • ParamArray may 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) then the ParamArray didn't 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 via LBound( ) and UBound( ).