[Gambas-user] Dim two-dimensional dynamic array

Tobias Boege tobs at taboege.de
Thu Sep 2 14:49:16 CEST 2021

On Thu, 02 Sep 2021, Dag Jarle Nerland Johansen - Gambas wrote:
> Hi,
> I didn't find how to declare a dynamic two-diemnsional array.
> One-dimension I make like this:
> Public arr As New String[]
> and then simply use the add-method.
> I see two-dimensions are declared like this
> Dim arr As New String[3, 8]
> I want to read in MySQL records in the arrays, because I repeat the use of
> them during the process of generating form and class, and that takes too
> much time, the programm got slow. And as I dont know how many records I get,
> I need it dynamicly. The same is for the amount of fields, different tables.

In Gambas you can always create an array containing objects of type T
by doing

  Dim a As New T[]

Now, to get a two-dimensional array, make an array of arrays:

  Dim a As New T[][]

You access one object via a[i][j] (_not_ via a[i,j]). And of course
you can add new rows to a and new columns to a given row a[i] as you
normally do with arrays.


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

More information about the User mailing list