Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Three-Dimensional Arrays

Status
Not open for further replies.

dangb333

MIS
May 21, 2001
2
0
0
CA
HI.
Do you know how to declare and write the coding for three dimensional arrays...
For example, i'm trying to make a 10 x 10 grid with labels, how would I be able to make an array read diagonally, without using the grid tool because i don't have that tool on my VB3.
Thanks.
 
A 10x10 grid?

Maybe what you really want is a two-dimensional array instead. I'm not sure how you intend to read diagonally, but here is how you declare an array:

Code:
Dim Array(10, 10) As String

This declares a two-dimensional array of 11 * 11, a total of 121, with Option Base 0 (the default).

Code:
Dim Array(10, 10, 10) As String

This declares a three-dimensional array of 11 * 11 * 11, a total of 1331, with Option Base 0.

As you can see the three-dimensional array is over 10x bigger, so use only what you need.

NOTE: You can change the type to what suits your application, e.g. variable/fixed length String, or Integer. I wouldn't recommend Variants because of their size.

If you want the array to start at 1, use lower To upper.

Code:
Dim Array(1 To 10, 1 To 10, 1 To 10) As String

------------

If you want to store values in an array, you can do this:

Code:
Array(x, y[, z]) = Value

To store a string in a three dimensional array (of String type):

Code:
Array(6, 3, 1) = "LabelX"

------------

If you give more specific information it may be easier to understand what you're trying to do, but I hope this helps you.

"For Lucky Best Wash Use Mr Sparkle."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top