[AccessD] Array questions

Arthur Fuller fuller.artful at gmail.com
Mon Jan 16 20:44:28 CST 2023


I was close. I forgot to include the parents in the references.

Thanks


On Monday, January 16, 2023, Stuart McLachlan <stuart at lexacorp.com.pg>
wrote:

> On 16 Jan 2023 at 18:16, Arthur Fuller wrote:
>
> > 1. How can I dimension an array to a given size?
>
>  DIM myArray( 1 to 10) AS STRIN
>
> 2. How to search an array for a given element? (Returning the element
> > number or 0 if not found)
>
> Dim lArrPtr as Long
> DIm i as long
> For i = LBound(myArray()) to UBOUND(myArray)
> If myArray(i) = sTestString then l = i
> Next
>
>  3. How to determine the length of an array?
>
> You mean the number of elements?
> UBOUND(myArray) - LBOUND(myArray) + 1
>
> > 4. Can I prefill an array when I declare it, I.e. fill it with zeroes
> > on the same line as its Dim?
>
> No.
> You have to do it in two steps.
> Nor can you assign a collection of values to multiple array elements. in
> one statement.
>
> A numeric array is autofilled with zero, a string array is "autofilled"
> with  zero length strings.
> If you want to populate then with anything else, you can do it in a loop
>
> For i = LBound(myArray()) to UBOUND(myArray)
> myArray(i) = " "
> Next
>
> 5. Given 2 arrays of equal length, can I
> > create a 2D array with 2 rows and assign an array to each?
>
> You can create an array with two COLUMNS
>
> > Given two arrays a1 and a2, both populated;
>
> For i = LBound(myArray()) to UBOUND(myArray)
>     a3(i,1) = a1(i)
>     a3(i,2) = a2(i)
> Next
>
> >
> > Dim a3( a1, a2)
> >
> > Why not?
>
> Because that is nonsense? That's not what DIM does.
>
> --
> 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