Microsoft KB Archive/33735

= 255 Dimensions Per Array in Interpreter, 7 in Compiler =

Article ID: 33735

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 1.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh

-



This article was previously published under Q33735



SUMMARY
The following information applies to Microsoft QuickBASIC Version 1.00, BASIC Compiler Version 1.00, and BASIC Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

The maximum number of dimensions an array can have in the interpreter is 255, which may be more than you could ever use because memory is quickly used up by arrays with a large number of dimensions.

The maximum number of array dimensions a compiled program can have is seven.

The maximum number of array elements per dimension allowed in both the interpreter and compiler is 32,767.



MORE INFORMATION
Please remember that base elements of arrays start with element number zero (OPTION BASE 0) by default. In other words, DIM X(20) dimensions X with 21 elements, X(0) through X(20). If you do not ever use element zero in any dimension, you should invoke OPTION BASE 1 at the top of your program to save memory. This process is especially important if you make an array with a large number of dimensions.

The following array has seven dimensions with two elements per dimension, giving it a total of 128 (2 to the power of 7) elements: OPTION BASE 1 DIM X(2,2,2,2,2,2,2) If you took out the OPTION BASE 1 statement, the default base element of the array would be &quot;0&quot;, and the array would have three elements per dimension, giving a total of 2187 (3 to the power of 7) elements. Notice how the OPTION BASE greatly affects allocated memory if you have a multi-dimensional array.

Additional query words: BasicCom MQuickB

Keywords: KB33735

-

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

© Microsoft Corporation. All rights reserved.