From: andrews on
Hi,
I have a question (maybe a stupid one)
I have too make some variables like
dim matrix5(5,5) as integer
dim matrix6(6,6) as integer
......
dim matrix10(10,10) as integer
this can be done but I want a shorter way like

dim str as string
dim i as integer

for i = 5 to 10
str = "matrix" & i.tostring
dim str(i,i) as integer
next i

but this gives a error
is it possible to do somthing like this without a error
it is long ago but i think it could be make in dbase3
thanks for any response
From: Andrew Morton on
andrews wrote:
> I have a question (maybe a stupid one)
> I have too make some variables like
> dim matrix5(5,5) as integer
> dim matrix6(6,6) as integer
> .....
> dim matrix10(10,10) as integer
> this can be done but I want a shorter way like
>
> dim str as string
> dim i as integer
>
> for i = 5 to 10
> str = "matrix" & i.tostring
> dim str(i,i) as integer
> next i
>
> but this gives a error
> is it possible to do somthing like this without a error
> it is long ago but i think it could be make in dbase3
> thanks for any response

What do you ultimately want to do with those arrays? A different type of
variable might be more suitable.

You can have an array of arrays:

Dim a(10)(,) As Integer
For i = 5 To 10
ReDim a(i)(i, i)
Next

although it makes me cringe to do that.

Or you could write a program to output the text you need to specify the
variables and paste that into your code.

--
Andrew


From: Cor Ligthert[MVP] on
Don't you know this one?

http://www.indyproject.org/Sockets/index.en.aspx


"andrews" <andrews(a)pandora.be> wrote in message
news:hh9Gn.27239$dB2.10318(a)newsfe22.ams2...
> Hi,
> I have a question (maybe a stupid one)
> I have too make some variables like
> dim matrix5(5,5) as integer
> dim matrix6(6,6) as integer
> .....
> dim matrix10(10,10) as integer
> this can be done but I want a shorter way like
>
> dim str as string
> dim i as integer
>
> for i = 5 to 10
> str = "matrix" & i.tostring
> dim str(i,i) as integer
> next i
>
> but this gives a error
> is it possible to do somthing like this without a error
> it is long ago but i think it could be make in dbase3
> thanks for any response
>
From: andrews on
What I want is that I can make many arrays of different dimensions on a
easy (short) way.
Sorry, there is no satisfaction with the given answers.
Maybe it is impossible.
Thanks any way.
From: Cor Ligthert[MVP] on
Andrew,

Sorry I pasted in the wrong answer.

Arrays of different dimensions is an old way.

Now those things are called collections or lists.

By instance
Dim myList as new List(of String)

is in fact an array of Strings,

Although there is also the oldest one in Net the ArrayList, which is in fact
the base of those, which is an List(array) of objects

Success,

Cor

"andrews" <andrews(a)pandora.be> wrote in message
news:JVrGn.19117$bq.9946(a)newsfe30.ams2...
> What I want is that I can make many arrays of different dimensions on a
> easy (short) way.
> Sorry, there is no satisfaction with the given answers.
> Maybe it is impossible.
> Thanks any way.
>