Redim: Array Already Dimensioned Msg After Dim w/ Subscripts

ID: Q83238


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


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.


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 query words: 2.00 3.00

Keywords :
Version :
Platform :
Issue type :


Last Reviewed: September 17, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.