Home All Groups Group Topic Archive Search About
Author
11 May 2010 9:18 AM
andrews
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

Author
11 May 2010 10:01 AM
Andrew Morton
andrews wrote:
Show quoteHide quote
> 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
Author
11 May 2010 10:47 AM
Cor Ligthert[MVP]
Don't you know this one?

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


Show quoteHide quote
"andrews" <andr***@pandora.be> wrote in message
news:hh9Gn.27239$dB2.10318@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
>
Author
12 May 2010 6:29 AM
andrews
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.
Author
12 May 2010 7:47 AM
Cor Ligthert[MVP]
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

Show quoteHide quote
"andrews" <andr***@pandora.be> wrote in message
news:JVrGn.19117$bq.9946@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.
>
Author
13 May 2010 10:13 AM
Michel Posseth [MCP]
I would like to add to that that now in VB 10 there is also the option to
create in a easy way a "true" matrix

XXXXXXXXXXXXXXXXXXXX
XXXXXX  XXXX   XXX  XXXX
XX XXXX  XXX  XXXXXXXXX
                XXXX XXXXXXXXXX
XXXX        XXXXXX

where every X could be of  a different datatype

You can acomplish this with a dictionary type and the new generic  Tuple
class


HTH


Michel Posseth


Show quoteHide quote
"Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> schreef in bericht
news:Ohtorda8KHA.1560@TK2MSFTNGP02.phx.gbl...
> 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" <andr***@pandora.be> wrote in message
> news:JVrGn.19117$bq.9946@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.
>>