Microsoft KB Archive/83238

= Redim: Array Already Dimensioned Msg After Dim w/ Subscripts =

Article ID: 83238

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q83238



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 &quot;Array already dimensioned&quot; 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: KB83238

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.