Microsoft KB Archive/50638

From BetaArchive Wiki
Knowledge Base

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

Article ID: 50638

Article Last Modified on 11/21/2006

This article was previously published under Q50638


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 bug 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.

DIM arrayb&(50)
CALL Test(arrayb&())

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

Additional query words: QuickBas BasicCom buglist4.00 buglist4.00b buglist4.50 B_BasicCom SR# S891016-81

Keywords: KB50638