views:

974

answers:

2

I was just doing some yicky code and I thought, instead of using three dynamic arrays, as such:

dim x() as string, y() as string, z() as string

It will be nicer to have a 3 dimensional dynamic array. But; the help and my fumbling experiments has not revealed the method of defining them.

This does not work:

dim x()() or dim(,2) or dim(,)

Any ideas anyone?

+4  A: 

A dynamic array is declared the same way regardless of the number of dimensions (arrays in LotusScript can have up to 8 dimensions). According to your example I think it is a two dimensional array you want, where the first dimension is limited to three entries.

If you first declare the array as:

Dim x() As String

You can then specify bounds according to the following example:

Redim x( 0 To 2, 0 To 9 ) ' A two dimensional array

And if you need to enlarge the array later (and keep all the values) you can do it like this:

Redim Preserve x( 0 To 2, 0 To 99 )

Please keep in mind that only the bounds of last dimension can be changed once the number of dimensions of the array has been set.

Mattias Kihlström
+1  A: 

You could use lists instead of arrays.

Dim x list as String

That is fully dynamic and takes a string as index. List can't contain lists, but lists can contain objects, so you might want to do

Public Class ListContainer
   Public level2 List as String
End Class

This way you never need to REDIM preserve. A forall loops you savely through a list

stwissel