[AccessD] Parameter (argument) order
John Colby
jwcolby at gmail.com
Thu Feb 16 11:03:42 CST 2023
Ooops.
test
foobar
barfoo
On Thu, Feb 16, 2023 at 12:02 PM John Colby <jwcolby at gmail.com> wrote:
> Passing an array:
>
> Function processArr(Arr As Variant) As String
> Dim N As Variant
> Dim finalStr As String
> For N = LBound(Arr) To UBound(Arr)
> finalStr = finalStr & Arr(N)
> Next N
> processArr = finalStr
> End Function
>
> Function processArr2(Arr As Variant) As String
> Dim N As Variant
> Dim finalStr As String
> For Each N In Arr
> finalStr = finalStr & N
> Next N
> processArr2 = finalStr
> End Function
>
> Sub test()
> Dim fString As String
> fString = processArr(Array("foo", "bar"))
> Debug.Print fString
>
> fString = processArr2(Array("bar", "foo"))
> Debug.Print fString
> End Sub
>
> 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
>
--
John W. Colby
Colby Consulting
More information about the AccessD
mailing list