[AccessD] Swap two elements in an array

Stuart McLachlan stuart at lexacorp.com.pg
Thu Aug 25 18:19:18 CDT 2022

On 25 Aug 2022 at 8:52, Arthur Fuller wrote:
> Function SwapElements(ByRef a As Variant, nPos1 As Integer, nPos2 As
> Integer) _
>         As Boolean
>     Dim temp As Integer
>     temp = a(nPos1)
>     a(nPos1) = a(nPos2)
>     a(nPos2) = temp
>     SwapElements = True
> End Function

So what happens if a is an array of strings?  :)
As I said in my original reply:
"If you define Temp as a Variant, you can use it with any type of array."

Incidentally ByRef and As Variant are defaults, so you could just use:

Function SwapElements(a, nPos1 As Long, nPos2 As Long) As Boolean

More information about the AccessD mailing list