question about array

rekam

Freshman
Joined
Oct 7, 2003
Messages
43
Location
Switzerland
Hello
I have a multi-dimensional array like this :

Dim myStringArray(30, 3, 12) as String

The problem is that I need a dynamical multi-dimensional array and I have really no idea how to do it...

Thanks
 
Thanks Squirm

I found an anthor method with Collection

Dim list as new Collection()

Dim list1 as new Collection()
Dim list2 as new Collection()
Dim list3 as new Collection()

Then I put anything I want into these 3 lists and then :

list.Add(list1)
list.Add(list2)
list.Add(list3)

I don't know if it's very useful, but it works quite well. I just odn't know how to reach the values of each lists, but I'll find ;)
 
Argh, it doesn't work like I want :( ...
I tried with Squirm's solution, but every time I redim the array, I erase all the content inside.
With the collections, I have done something just like my precedent post, but it doesn't work.

I tried other solutions, something like that :
Dim myarray(30, 3, 1) as string
and put in the last dimension a collection of values (sometimes 4 values, sometimes 16, or anything else). But it returns me an error because a Collection....is not a String, of course.

Just now, I tried to use an ArrayList. I can create them dynamically : Dim myArrayList( , , ) as ArrayList, but if I want to put a integer or a string inside it on the position, let's say, (21, 1, 3), it tells me it's not an Array...

pff.....I don't know how to do, sob sob... Has someone an idea ?

Here's my problem :
I have an unknown number of parameters (for a game). Each parameter has between 2 and 4 types, and each type has 4 or more values. So a multi-dimensional array seems to be the best way to resolve this. But...
 
Well, in fact, all I would like to have is a :

Dynamical multi-dimensional String Array that we don't have to redim

That strange beast exists ?
 
Last edited:
Unfortunately, PlausiblyDamp, all the data are erased when redim, even with preserve...

Well, here is a part of my code. I have a Xml request which returns me some values (that is working).

PHP:
dim cpt, values as integer
for cpt = 0 to 20

'my request xml which depends on cpt
values = 0
while xmlResult.MoveNext()
values += 1
end while

if values = 2 then
redim preserve stringArray(30, 1, 1)
'the code for this section
else if values = 4 then
redim preserve stringArray(30, 3, 3)
'the code for this section
else
redim preserve stringArray(30, 3, 15)
'the code for this section
end if

next

The thing is : the first dimension of the stringArray is a key. And, for example, the key with the value "2" has only 1 case in the second dimension. The key "3" has 3 cases...It will be easy with dynamical array...But well, Preseve doesn't preserve the data allready entered in the stringArray.
 
Back
Top