Microsoft Office Development and Consultancy
|VBA > Arrays > Using ParamArray||< Previous | Next >|
The parameter array must be defined with a Variant datatype
The parameter array is always zero based and is not effected by the Option Base statement.
This can only be used as the last argument in a procedure or function
This keyword allows you to provide an arbitrary number of arguments that get submitted as an array.
This keyword cannot be used with ByRef, ByVal or Optional
'always zero based array
'array is always 2 dimensional with a 0 first dimension
ParamArray Optional. Used only as the last argument in arglist to indicate that the final argument is an Optional array of Variant elements.
The ParamArray keyword allows you to provide an arbitrary number of arguments.
ParamArray can't be used with ByVal, ByRef, or Optional.
1 or 2 Dimensional Array ?
Lets consider the following subroutine that accepts an array as its argument.
In this situation the array is passed in as a 1 dimensional array
vMyArray(0) = "One"
vMyArray(1) = "Two"
vMyArray(2) = "Three"
In this situation the array is passed in as a 2 dimensional array
vMyArray(0)(0) = "One"
vMyArray(0)(1) = "Two"
vMyArray(0)(2) = "Three"
Need to call the Array_ParamArray1Dimension function to convert this back to a 1 dimensional array.
|© Better Solutions Limited 15-Oct-2013||< Previous | Top | Next >|