[AccessD] Brain Fart regarding arrays

Arthur Fuller fuller.artful at gmail.com
Sat Jan 7 22:09:25 CST 2023


Thanks, Jack. I was pretty close in my vague recollection, just not close
enough. I'll spin this up.

I suppose the contents of the array suggests its purpose. I wrote a couple
of versions of the problem in C, and learned among other things that
testing for a leap year  and choosing which array row to use is way quicker
than trying any other method. So I thought to port it to VBA and compare,
not for absolute speed, but among VBA versions. I'll let you know how it
goes.

On Sat, Jan 7, 2023 at 9:40 PM jack drawbridge <jackandpat.d at gmail.com>
wrote:

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