[AccessD] Brain Fart regarding arrays

jack drawbridge jackandpat.d at gmail.com
Sat Jan 7 20:40:07 CST 2023


Arthur,

Here's a method that may satisfy your requirement. It's been a long time
since I did multi-dimension anything.
Hope it's helpful.

'=====arthur fuller


Sub Fill_2DArray()
    Dim intI As Integer, intJ As Integer
    Dim Arr1 As Variant, arr2 As Variant
    Arr1 = Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
    arr2 = Array(0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
    Dim TwoD(0 To 1, 0 To 12) As Integer

    ' Fill array with values.
    For intI = 0 To 1
        For intJ = 0 To 12
            Select Case intI
                Case 0
                    TwoD(intI, intJ) = Arr1(intJ)
                Case 1
                    TwoD(intI, intJ) = arr2(intJ)
            End Select
            Debug.Print "TwoD(" & intI & " , " & intJ & ")  is " &
TwoD(intI, intJ)
        Next intJ
        Debug.Print
    Next intI
End Sub

On Sat, Jan 7, 2023 at 8:54 PM Arthur Fuller <fuller.artful at gmail.com>
wrote:

> I can't remember at the moment how to populate a 2D array. I know what I
> want: 13 x 2:
>
> Row 1: (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
> Row 2: (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
>
> I seem to recall being able to populate it in two steps, passing the rows
> as described above, but I can't recall the syntax. I've been spending too
> much time in C and C++ and have forgotten my VBA. 🙁
>
> --
> Arthur
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>


More information about the AccessD mailing list