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

Arthur Fuller fuller.artful at gmail.com
Fri Feb 17 12:17:39 CST 2023


Shane,

Thanks much for the clarification. I appreciate it immensely.

As a totally irrelevant aside, I note that you and I share (at least) one
thing in common: both of us share a name with a well-known movie. In
your case, a classic, in mine a forgettable comedy. You win, hands down! 😀

On Fri, Feb 17, 2023 at 1:30 AM Shane Groff via AccessD <
accessd at databaseadvisors.com> wrote:

> Hi Arthur, Stuart gave you an example of how to declare a function that
> takes arrays as arguments:
>
> Function ArrayCompare(ar1() As String, ar2() As String) As Boolean
>
> The parentheses () after ar1 and ar2 indicate that these are arrays of
> Strings, not just strings.
>
> As Stuart also pointed out, since a Variant can hold an Array, you could
> use:
>
> Function ArrayCompare(ar1 As Variant, ar2 As Variant) As Boolean
>
> And pass in Arrays as arguments (but this would be less clear, unless you
> had some case where you wanted to pass in something other than an array).
>
> My point was simply that the documentation for ParamArray is correct, it
> just isn't designed for the problem you are trying to solve.
>
> Shane
>
> -----Original Message-----
> From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com>
> On Behalf Of Arthur Fuller
> Sent: Thursday, February 16, 2023 10:24 PM
> To: Access Developers discussion and problem solving <
> accessd at databaseadvisors.com>
> Subject: Re: [AccessD] [EXTERNAL] Re: Parameter (argument) order
>
> 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%2Fle
> > > arn.microsoft.com%2Fen-us%2Foffice%2Fvba%2Flanguage%2Fconcepts%2Fget
> > > ting&data=05%7C01%7Cshaneg%40microsoft.com%7Cfe4f20e8635c4d5f041508d
> > > b10afa42f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6381221188605
> > > 78677%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLC
> > > JBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=19kB%2FD0FQCP9Y21
> > > YHyrpeF1ZulVrm%2BecPu%2Bkpln%2BHBo%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%2Fdata
> > baseadvisors.com%2Fmailman%2Flistinfo%2Faccessd&data=05%7C01%7Cshaneg%
> > 40microsoft.com%7Cfe4f20e8635c4d5f041508db10afa42f%7C72f988bf86f141af9
> > 1ab2d7cd011db47%7C1%7C0%7C638122118860578677%7CUnknown%7CTWFpbGZsb3d8e
> > yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C30
> > 00%7C%7C%7C&sdata=pvd9iE12M85Lc7zq0Tif0Jwu8%2FLjg2i2a6Qd%2Fq158Ws%3D&r
> > eserved=0
> > Website:
> > https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.d
> > atabaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Cfe4f20e
> > 8635c4d5f041508db10afa42f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7
> > C638122118860578677%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIj
> > oiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4W8m9rL
> > ettQh6Zvfz%2FjFcrU1QBeetXyxAynYgoUs%2B1A%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%7Cfe4f20e8635c4d5f041508db10afa42f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122118860578677%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pvd9iE12M85Lc7zq0Tif0Jwu8%2FLjg2i2a6Qd%2Fq158Ws%3D&reserved=0
> Website:
> https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.databaseadvisors.com%2F&data=05%7C01%7Cshaneg%40microsoft.com%7Cfe4f20e8635c4d5f041508db10afa42f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638122118860578677%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=4W8m9rLettQh6Zvfz%2FjFcrU1QBeetXyxAynYgoUs%2B1A%3D&reserved=0
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
Arthur


More information about the AccessD mailing list