[AccessD] [EXTERNAL] Re: Parameter (argument) order

Stuart McLachlan stuart at lexacorp.com.pg
Fri Feb 17 00:08:05 CST 2023


On 17 Feb 2023 at 5:07, Shane Groff via AccessD wrote:

> https://learn.microsoft.com/en-us/office/vba/language/concepts/getting
> -started/understanding-parameter-arrays
> 
> A ParamArray is not for passing an array as an argument, it is for
> allowing you to pass a dynamic number of arguments as an array:
> 
> If you declare:
> Function CalcSum(ParamArray args() as Variant) As Double
> 
> You can call it like so:
> 
> x = CalcSum(34, 47, 99, 12)
> or
> x = CalcSum(1, 1)
> 
> and it can add all the arguments together (it receives all the
> arguments as a single array).
> 
> It must be the last argument in the declaration, since all the
> arguments at the end of the caller will be 'consumed' to create the
> array, so there can't be any additional arguments.
> 

Another way to pass a series of arguments as an array :)
Function PassArray() As Long
Dim v As Variant
v = Array("Some text", 2, 3)
UseArray v
End Function

Function UseArray(v As Variant) As Long
Debug.Print Mid$(v(0), v(1), v(2))
End Function


More information about the AccessD mailing list