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

Shane Groff shaneg at microsoft.com
Fri Feb 17 10:12:52 CST 2023


Yes, it is impressive. However, you need to use your own judgment, it cannot always be trusted.

For example, this is not true, "Note that when passing arrays to a function, you need to make sure that the arrays are of the same data type and have the same number of elements."

Shane

________________________________
From: AccessD <accessd-bounces+shaneg=microsoft.com at databaseadvisors.com<mailto:accessd-bounces+shaneg=microsoft.com at databaseadvisors.com>> on behalf of jack drawbridge <jackandpat.d at gmail.com<mailto:jackandpat.d at gmail.com>>
Sent: Friday, February 17, 2023, 7:12 AM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com<mailto:accessd at databaseadvisors.com>>
Subject: Re: [AccessD] [EXTERNAL] Re: Parameter (argument) order


Yes John, quite impressive.


On Fri, Feb 17, 2023 at 9:51 AM John Colby <jwcolby at gmail.com<mailto:jwcolby at gmail.com>> wrote:

> LOL, how cool is that.
>
> On Fri, Feb 17, 2023 at 8:46 AM jack drawbridge <jackandpat.d at gmail.com<mailto:jackandpat.d at gmail.com>>
> wrote:
>
> > Arthur,
> > I submitted your question to chatgpt and received a response as follows.
> >
> ------------------------------------------------------------------
> > Ms access how to pass 2 arrays to a function that compares the arrays
> > element by element and returns false if they are not equivalent?
> >
> > To pass two arrays to a function in MS Access VBA and compare them
> element
> > by element, you can follow these steps:
> >
> >     Declare a function that accepts two arrays as arguments. For example:
> >
> > vbnet
> >
> > Function CompareArrays(arr1() As Variant, arr2() As Variant) As Boolean
> >     ' Your code here
> > End Function
> >
> > In this example, we're declaring a function called CompareArrays that
> > accepts two arrays of Variant type as arguments.
> >
> >     In the function body, loop through the elements of the arrays and
> > compare them element by element. If any of the elements are not equal,
> > return False. If all of the elements are equal, return True. For example:
> >
> > vbnet
> >
> > Function CompareArrays(arr1() As Variant, arr2() As Variant) As Boolean
> >     Dim i As Integer
> >
> >     If UBound(arr1) <> UBound(arr2) Then
> >         CompareArrays = False
> >         Exit Function
> >     End If
> >
> >     For i = 0 To UBound(arr1)
> >         If arr1(i) <> arr2(i) Then
> >             CompareArrays = False
> >             Exit Function
> >         End If
> >     Next i
> >
> >     CompareArrays = True
> > End Function
> >
> > In this example, we're first checking if the length of the two arrays is
> > equal. If they are not, we return False. Then, we loop through the
> elements
> > of the arrays using the For loop and compare them element by element. If
> > any of the elements are not equal, we return False. If all of the
> elements
> > are equal, we return True.
> >
> >     To call the function, create two arrays and pass them to the function
> > as arguments. For example:
> >
> > scss
> >
> > Dim arr1(2) As Variant
> > Dim arr2(2) As Variant
> >
> > arr1(0) = 1
> > arr1(1) = 2
> > arr1(2) = 3
> >
> > arr2(0) = 1
> > arr2(1) = 2
> > arr2(2) = 4
> >
> > Debug.Print CompareArrays(arr1, arr2) ' Returns False
> >
> > In this example, we're creating two arrays arr1 and arr2, filling them
> with
> > elements and passing them to the CompareArrays function. The function
> > returns False because the last element of arr1 and arr2 are different.
> >
> > Note that when passing arrays to a function, you need to make sure that
> the
> > arrays are of the same data type and have the same number of elements.
> >




More information about the AccessD mailing list