Export (0) Print
Expand All

Array Bounds for Visual Basic 6.0 Users 

Visual Basic 2005 updates the declaration of array bounds to provide interoperability with arrays in other programming languages.

Visual Basic 6.0

In Visual Basic 6.0, the default lower bound of every dimension of an array is 0. You can change this to 1 with the Option Base statement. You can also override the default lower bound in individual array declarations.

If you leave the default at 0, the number of elements in the array is equal to the upper bound plus one. The following declaration reserves 21 elements for the array Weight:

Dim Weight(20) As Single

Visual Basic 2005

In Visual Basic 2005, the lower bound of every array dimension is 0, and you cannot declare it to be otherwise. The Option Base statement is not supported.

The number you specify for each dimension in the declaration is the upper bound, and the initial element count is equal to the upper bound plus one. The declaration in the preceding example reserves 21 elements for Weight, with indexes 0 through 20.

You can also specify a zero-length array, which does not contain any elements, by declaring one of its upper bounds to be –1.

See Also

Community Additions

ADD
Show:
© 2015 Microsoft