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

Shane Groff shaneg at microsoft.com
Fri Feb 17 09:50:10 CST 2023


Yes. ByRef is a good idea for array parameters since it could be expensive to copy them. (Omitted from examples for brevity since it isn't required)

Shane

________________________________
From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com> on behalf of Rocky Smolin <rockysmolin2 at gmail.com>
Sent: Friday, February 17, 2023, 6:49 AM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] [EXTERNAL] Re: Parameter (argument) order

Can't you use byref in the function for the parameters?

Passing Arguments by Value and by Reference - Visual Basic | Microsoft Learn
<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Fdotnet%2Fvisual-basic%2Fprogramming-guide%2Flanguage-features%2Fprocedures%2Fpassing-arguments-by-value-and-by-reference&data=05%7C01%7Cshaneg%40microsoft.com%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bSNwINj0lyjs414cAhAp%2FfODceDzDpz8LXUNryrleoY%3D&reserved=0>

r

On Thu, Feb 16, 2023 at 10:24 PM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> Thanks for trying, Stuart. You know that I love your mind and intellect.
> But apparently I am still failing to pose my question properly. Let me try
> once more. I want to pass two arrays to a function, and then do whatever I
> want with them. One simple possibility is to compare them. Another is to
> concatenate them and return the result. A third is to "subtract" them and
> return the difference as a tiny array. Another is to perform a
> matrix-multiplication on them, and return that result.
>
> the template is simple:
> Function arrManipulate(a1,a2) as <whatever>    'not sure how to declare the
> args; as Variant?
> Do Somestuff with a1 and a2       ' they are both arrays
> Return SomeResult
> End Function
>
> Maybe I'm missing something in VBA, but so far I can't seem to get from
> here to there. It's easy in C and C++, but I have not yet arrived at the
> equivalent method in VBA.
>
> On Fri, Feb 17, 2023 at 1:08 AM Stuart McLachlan <stuart at lexacorp.com.pg>
> wrote:
>
> > On 17 Feb 2023 at 5:07, Shane Groff via AccessD wrote:
> >
> > > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flearn.microsoft.com%2Fen-us%2Foffice%2Fvba%2Flanguage%2Fconcepts%2Fgetting&data=05%7C01%7Cshaneg%40microsoft.com%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=x1lfg4T7dSFZ1SRDhJloZF5O84Lv4hi2R0dKo23My%2B8%3D&reserved=0
> > > -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
> > --
> > 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%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RdVPgpBANy%2B8c9DEZ2mnKvy%2FJXFNnsWiT622RL7Vmas%3D&reserved=0
> > Website: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.databaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FOl2OLMvJW7BBuf8%2FqSs4h%2Fb6XqvokEn8r%2FNi0yXxAg%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%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RdVPgpBANy%2B8c9DEZ2mnKvy%2FJXFNnsWiT622RL7Vmas%3D&reserved=0
> Website: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.databaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FOl2OLMvJW7BBuf8%2FqSs4h%2Fb6XqvokEn8r%2FNi0yXxAg%3D&reserved=0
>
--
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%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RdVPgpBANy%2B8c9DEZ2mnKvy%2FJXFNnsWiT622RL7Vmas%3D&reserved=0
Website: https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.databaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Ccdc03f6bba7844ed38ba08db10f62c98%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122421733354419%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FOl2OLMvJW7BBuf8%2FqSs4h%2Fb6XqvokEn8r%2FNi0yXxAg%3D&reserved=0



More information about the AccessD mailing list