Home All Groups Group Topic Archive Search About
Author
29 Mar 2005 3:35 PM
Agnes
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

Author
29 Mar 2005 4:14 PM
Rob Windsor [MVP]
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/



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
>
>
Author
30 Mar 2005 2:39 AM
Agnes
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
>>
>>
>
>
Author
29 Mar 2005 4:24 PM
Herfried K. Wagner [MVP]
"Agnes" <ag***@dynamictech.com.hk> schrieb:
>I know how to use arraylist but it seems IT is one-D array.
> How can I declare Two-D array ??

Make sure you have read the article below:

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/>
Author
29 Mar 2005 4:43 PM
Cor Ligthert
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