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

Arthur Fuller fuller.artful at gmail.com
Fri Feb 17 00:24:20 CST 2023


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://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
> --
> 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