PDA

View Full Version : Solved: Multidimensional Array



asingh
09-12-2007, 03:53 AM
Hi,

How do I declare a multidimensional array [2--way] in VBA..??

thanks..

asingh

Bob Phillips
09-12-2007, 04:01 AM
Depends upon how you want to populate it.

You can dimension it in the declaration


Dim ary(1 To 3, 1 To 5)


or just declare it as variant and redim later


Dim ary

ReDim ary(1 To 3, 1 To 5)

rory
09-12-2007, 04:24 AM
You can also declare it as a specific datatype in the Dim statement, or declare as a variant and then specify the type in the Redim. You cannot however declare an array as one type in the Dim statement and then change type in the Redim.

unmarkedhelicopter
09-12-2007, 04:38 AM
Or you could define a UDT then declare an array as that (saves memory)

RECrerar
09-12-2007, 04:46 AM
Currently just for interests sake, what's a UDT?

rory
09-12-2007, 04:53 AM
It's a User Defined Type. And while you could do that, I don't know why you would in most cases.

Bob Phillips
09-12-2007, 05:48 AM
Nor I. They are a good idea that has been badly implemented, so personally I avoid them. I would use a class over a UDT every time.

rory
09-12-2007, 05:56 AM
Likewise, though I believe the VB.Net and VB 2005 implementation of them (structures) is much better.

asingh
09-16-2007, 01:31 PM
thanks...all...!

regards, asingh