KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q50638: "Subscript Out Of Range" If REDIM Long Integer Array in SUB

Article: Q50638
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist4.00 buglist4.00b buglist4.50 B_BasicCom SR# S891016- | mspl13_basic
Last Modified: 15-DEC-1989

REDIMing (redimensioning with REDIM) a dynamic long integer array that
was passed to a SUBprogram generates a "Subscript Out Of Range" error
at run time.

Microsoft has confirmed this to be a problem in Microsoft QuickBASIC
Versions 4.00, 4.00b, and 4.50 for MS-DOS and in Microsoft BASIC
Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2 (buglist6.00,
buglist6.00b). This problem was corrected in Microsoft BASIC PDS
Version 7.00 (fixlist7.00).

The "Subscript Out Of Range" occurs whether the SUBprogram is compiled
as part of the main program or it is compiled in a separate module.

You can work around this problem by using an array type other than
long integer, or by passing the array through a COMMON SHARED block.

The following code demonstrates the problem passing a dynamic array of
long integers to a SUBprogram and REDIMing it in the SUBprogram.

REM $DYNAMIC
DIM arrayb&(50)
CALL Test(arrayb&())
END

SUB Test(arrayc&())
   REDIM arrayc&(100)
END SUB

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.