VB Redim "Array Already Dimensioned" After Dim with Subscripts

ID Number: Q83238

1.00

WINDOWS

Summary:

You can use the ReDim statement to redimension a dynamic array only if

the array has been previously dimensioned with empty parentheses (no

subscripts), or if the array has been previously redimensioned with

ReDim. If you specified subscripts to originally dimension the array

in a Global or Dim statement, or if you previously dimensioned the

array using the Static statement in a Sub or Function, redimensioning

the array will cause an "Array already dimensioned" error.

This information applies to Microsoft Visual Basic programming system

version 1.0 for Windows.

More Information:

You can use the ReDim statement to dimension an array that you have

already declared with empty parentheses either in the Global module or

in the general Declarations section. You can also use ReDim to

redimension arrays that you have dimensioned with ReDim previously

from any Sub or Function procedure.

Therefore, if you need to redimension an array in your program after

using the array, first dimension the array in the Global module using

the Global statement, or in the general Declarations section using Dim

with no subscripts. Then use ReDim with the original dimensions.

Later on, you can redimension this array again with different

subscripts.

This will enable you to change the number of subscripts in each

dimension of an array [for example, from x(15, 15) to x(32, 24)].

However, you cannot use ReDim to change the number of dimensions in an

array. For example, you cannot redimension an array from two

dimensions, such as x(15, 15), to three dimensions, such as

x(64, 1, 5).

Additional reference words: 1.00