Array Size Declaration for Visual Basic 6.0 Users
Visual Basic 2008 updates array size declaration for interoperability with the common language runtime.
In Visual Basic 2008, an array does not have a permanent size. The preceding example can be rewritten as either of the following declarations:
These declarations are equivalent. Each specifies an initial size, which you can change during execution with the ReDim statement. To initialize the elements, you can use the following syntax:
If you specify –1 for one of the dimensions, the array does not contain any elements. A ReDim statement can change an array back and forth between empty and nonempty.
Although an array's size can change in Visual Basic 2008, the number of dimensions must be fixed. The following example declares a three-dimensional array:
The ReDim statement can set or change the size of each dimension, but the array always remains three-dimensional.