Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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 ;)

Posted

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...

Posted (edited)

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 ?

Edited by rekam
Posted

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).

 

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...