Declaring Arrays
An array must be declared, since it is a type of
variable. You use the Public
or Dim statement to declare
arrays just as you would use them for declaring individual
variables. You can create an array of any data type,
so dataType can be integer, Double, etc. An array
containing five elements, all of which are integers,
can be declared as follows:
Dim intValues(5) as Integer
Dim intValues(1 To 5) as Integer
Both the above statements are equivalent. An array
name must be chosen according to the same rules used
for naming other variables. The name of the array
cannot be the same as that of any other variable declared
within the function.
|
All the elements of an array are
of the same type. |
You can specify the starting and ending subscripts
values. Consider the following declaration:
Dim intValues (50 To 100) As Integer
With the above declaration, if you try to access
intValues (10), VB would generate an error because
subscripts don't begin until 50.
|