Update dynamic array

Hello,

I want to use a dynamic array in Lotusscript.

I want to start with an array of 1 row and 2 columns.

After that, I want to increase the row every time with one.

This is my code :

Dim myNames() As String

Redim myNames(arr_row,arr_col)

myNames(arr_row,arr_col) = "Line1"

Messagebox myNames(arr_row,arr_col)



arr_row = arr_row + 1

Redim Preserve myNames(arr_row ,arr_col) 

myNames(arr_row,arr_col) = "Line2"	

Messagebox myNames(arr_row,arr_col)

I get the message ‘Subscript out of range’ with the 2nd messagebox.

How can I resolve this?

Thanks in advance

Greetings

Lainkes

Subject: From Designer Help

You’re actually getting the error on the 2nd Redim not the 2nd Messagebox

From the designer help:

If Preserve is specified, you can change only the upper bound of the last array dimension. Attempting to change any other bound results in an error.

Also, it’s probably better to use properly declared and initialized integers for your bounds rather than letting it fall back on Variant.

Also, I’m not sure you’ve managed to get an array with one row and two columns to begin with. You probably want to start with bounds(0,1) which would give you positions (0,0) and (0,1) for the first “row”. Then the second row would be (1,0) and (1,1). However, due to the above limitation, attempting to do this dynamically is not a useful endeavour.

Why not use two single dimension arrays?

column0(n) and column1(n).

Subject: What’s a row and what’s a column?

Alain, another way to solve this problem is to turn your head sideways as you code, so that the “rows” parameter becomes the one you can change with a redim.