GBIC: Arrays
The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.
Arrays are variables which hold multiple values. Each of the values is indexed.
Declare an array with Dim
Arrays default to a lower bound of zero but the user must specify the upper bound
Dim MyArray(5) As Long '6 elements, 0-6
'Users can define the upper/lower bounds
Dim MyArray(1 To 15)
Dim MyArray( - 10 To 10)
'Arrays can have multiple dimensions
Dim MyArray(5,5)
Dim MyArray(1 To 10, 1 To 50)
Arrays whose dimensions are set with Dim are fixed-size arrays. The dimensions cannot be changed.
Arrays whose dimensions can be changed are called dynamic arrays. They are declared with ReDim and later dimensioned again, as often as needed
Redim MyArray() 'dynamic array
then later in code:
Redim MyArray(15) 'the dimensions can be changed at any time to any value
ReDim loses values in the array unless Preserve is used
Redim Preserve MyArray(15)
Control arrays
Variables can contain objects, such As textboxes Or pictureboxes, And VB supports arrays of objects As well.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.