|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
making variablesI 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 andrews wrote:
Show quoteHide quote > I have a question (maybe a stupid one) What do you ultimately want to do with those arrays? A different type of > 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 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 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 > 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. 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. > 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. >> |
|||||||||||||||||||||||