There are various array dimensions in Visual Basic. A direction in which you can vary the specification of an array's elements is known as a dimension. Consider the following examples for different types of the arrays :
- An array that holds the sales total for each day of the month has one dimension (the day of the month).
- An array that holds the sales total by department for each day of the month has two dimensions (the department number and the day of the month).
The number of dimensions an array has is called its rank. By supplying an index or subscript for each of its dimensions, you can specify an element of an array.
Types of the Dimensions :
One Dimension - Many arrays have only one dimension, such as the number of people of each age.The following example declares a variable to hold a one-dimensional array of age counts for ages 0 through 100.
Code:
Dim ageCounts(100) As UInteger
Two Dimensions - Some arrays have two dimensions, such as the number of offices on each floor of each building on a campus. The following example declares a variable to hold a two-dimensional array of office counts, for buildings 0 through 25 and floors 0 through 10.
Code:
Dim officeCounts(25, 10) As Byte
Three Dimensions - A few arrays have three dimensions, such as values in three-dimensional space. The following example declares a variable to hold a three-dimensional array of air temperatures at various points in a three-dimensional volume.
Code:
Dim airTemperatures(55, 75, 35) As Single
More than Three Dimensions - Although an array can have as many as 32 dimensions, it is rare to have more than three.
Bookmarks