|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Two D array ??I know how to use arraylist but it seems IT is one-D array.
How can I declare Two-D array ?? Please be kind to give me a little sample. thanks a lot If you want a fixed sized array then you can use an array class. For example
if you want a 10x5 array of integers then the syntax would be: Dim intArray(9, 4) As Integer If you want a ragged array then you could have one ArrayList holding references to other ArrayLists. Off the top of my head the syntax to access an element in this structure would be: Dim i As Integer i = CInt(CType(raggedArray(3), ArrayList)(4)) Show quoteHide quote "Agnes" <ag***@dynamictech.com.hk> wrote in message news:ei3z0UHNFHA.164@TK2MSFTNGP12.phx.gbl... >I know how to use arraylist but it seems IT is one-D array. > How can I declare Two-D array ?? > Please be kind to give me a little sample. thanks a lot > > I need to store the string, but not the integer ...
I try Dim myString(,) as string. myString(0,0) = "ID" myString(0,1) = "Name" However, I got an error "object reference not set to an instance of an object" Show quoteHide quote "Rob Windsor [MVP]" <rob.windsor.no.spam@gmail.com> ¼¶¼g©ó¶l¥ó·s»D:uF97EoHNFHA.3***@TK2MSFTNGP12.phx.gbl... > If you want a fixed sized array then you can use an array class. For > example if you want a 10x5 array of integers then the syntax would be: > > Dim intArray(9, 4) As Integer > > If you want a ragged array then you could have one ArrayList holding > references to other ArrayLists. Off the top of my head the syntax to > access an element in this structure would be: > > Dim i As Integer > i = CInt(CType(raggedArray(3), ArrayList)(4)) > > -- > Rob Windsor [MVP-VB] > G6 Consulting > Toronto, Canada > http://msmvps.com/windsor/ > > > > "Agnes" <ag***@dynamictech.com.hk> wrote in message > news:ei3z0UHNFHA.164@TK2MSFTNGP12.phx.gbl... >>I know how to use arraylist but it seems IT is one-D array. >> How can I declare Two-D array ?? >> Please be kind to give me a little sample. thanks a lot >> >> > > "Agnes" <ag***@dynamictech.com.hk> schrieb: Make sure you have read the article below:>I know how to use arraylist but it seems IT is one-D array. > How can I declare Two-D array ?? Visual Basic Language Concepts -- Declaring Array Variables <URL:http://msdn.microsoft.com/library/en-us/vbcn7/html/vacondeclaringarrays.asp> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Agnes,
Why are you not using when you want a two D array a datatable. It is in my opinion so much easier to use. Cor |
|||||||||||||||||||||||