[AccessD] Parameter (argument) order

John Colby jwcolby at gmail.com
Thu Feb 16 10:52:44 CST 2023


A ParamArray is not a string, it is an array of parameters.

https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/understanding-parameter-arrays

Sub AnyNumberArgs2(strName As String, ParamArray intScores() As Variant)
 Dim varParam As Variant

 Debug.Print strName; " Scores"
 ' Use UBound function to determine upper limit of array.
 For Each varParam In intScores()
    Debug.Print " "; varParam
 Next varParam
End Sub

AnyNumberArgs2 "Jamie", 10, 26, 32, 15, 22, 24, 16
Jamie Scores
  10
  26
  32
  15
  22
  24
  16

AnyNumberArgs2 "Kelly", "High", "Low", "Average", "High"
Kelly Scores
 High
 Low
 Average
 High

On Thu, Feb 16, 2023 at 11:08 AM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> I thought not. On the other hand, it does make sense to pattern my own
> functions after the conventions established by existing functions, such as
> Instr() or Mid(), etc.
>
> According to Microsoft Learn:
> You use the ParamArray keyword to denote a parameter array. The array must
> be declared as an array of type Variant,
> and it must be the last argument in the procedure definition.
>
> The thing that bugs me is that the only way to pass an array is by using
> ParamArray, which must be the last argument. Not that I care about the
> order, and it makes sense that it must be the last argument, but now I want
> to experiment and see whether I can pass two parameter arrays, say to a
> function called arrCompare(a1, a2) As Boolean. In C or C++ it's easy. In
> VBA, not so much. Still thinking this out.
>
> I think it's time that I began investigating how to create DLLs in C and/or
> C++ for use in VBA.
>
> On Wed, Feb 15, 2023 at 10:42 PM Stuart McLachlan <stuart at lexacorp.com.pg>
> wrote:
>
> > It makes no difference at all
> >
> > On 15 Feb 2023 at 18:34, Arthur Fuller wrote:
> >
> > > Given any function F( arg1 as whatever, arg2 as whatever, arg3 as
> > > whatever), is there any reason to choose one or another order of the
> > args?
> > > Or is it just a whim of the programmer at the moment of creation? Let
> us
> > > suppose that args 1 and 3 are Longs, and arg2 is a string.
> > >
> > > Opinions invited.
> > >
> > > --
> > > Arthur
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


-- 
John W. Colby
Colby Consulting


More information about the AccessD mailing list