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

Shane Groff shaneg at microsoft.com
Thu Feb 16 23:07:57 CST 2023


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.

Shane


-----Original Message-----
From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com> On Behalf Of Arthur Fuller
Sent: Thursday, February 16, 2023 8:49 PM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: [EXTERNAL] Re: [AccessD] Parameter (argument) order

Hi Stuart,

Thanks for this which I shall promptly test, but to answer your question, I got it from the docs at Microsoft Learn. I should have known better. :)

On Thu, Feb 16, 2023 at 10:52 PM Stuart McLachlan <stuart at lexacorp.com.pg>
wrote:

> On 16 Feb 2023 at 11:08, Arthur Fuller wrote:
>
> > The thing that bugs me is that the only way to pass an array is by 
> > using ParamArray, which must be the last argument.
>
> Where did you get that idea?
>
> Function paramtest() As Long
> Dim a(10) As String
> Fillarr a(), 3, "Hello"
> Debug.Print a(3)
> End Function
>
> Function Fillarr(arr() As String, idx As Long, sVal As String) As Long
>    arr(idx) = sVal
> End Function
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdata
> baseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cshaneg%
> 40microsoft.com%7Cd07e69637258463fa50608db10a25860%7C72f988bf86f141af9
> 1ab2d7cd011db47%7C1%7C0%7C638122061698024300%7CUnknown%7CTWFpbGZsb3d8e
> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C30
> 00%7C%7C%7C&sdata=Ll1ZlFp7RNCBnvmw20dwN%2FIdDfRxoJZrEQpmxe3MbwQ%3D&res
> erved=0
> Website: 
> https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.d
> atabaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Cd07e696
> 37258463fa50608db10a25860%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7
> C638122061698024300%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj
> oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p0hwAn0
> hC138Y4lpJ38EzWVXGk%2FQuXyGHohWMyHruwI%3D&reserved=0
>


--
Arthur
--
AccessD mailing list
AccessD at databaseadvisors.com
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdatabaseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cshaneg%40microsoft.com%7Cd07e69637258463fa50608db10a25860%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122061698024300%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ll1ZlFp7RNCBnvmw20dwN%2FIdDfRxoJZrEQpmxe3MbwQ%3D&reserved=0
Website: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.databaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Cd07e69637258463fa50608db10a25860%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122061698024300%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=p0hwAn0hC138Y4lpJ38EzWVXGk%2FQuXyGHohWMyHruwI%3D&reserved=0


More information about the AccessD mailing list