By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,027 Members | 1,257 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,027 IT Pros & Developers. It's quick & easy.

Two D array ??

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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:ei*************@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

Nov 21 '05 #2

P: n/a
"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/>

Nov 21 '05 #3

P: n/a
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
Nov 21 '05 #4

P: n/a
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"

"Rob Windsor [MVP]" <ro*****************@gmail.com> glsD:uF**************@TK2MSFTNGP12.phx.g bl...
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:ei*************@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


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.