Microsoft KB Archive/93674

= Run in Procedure That Dimensions Array Hangs VB Environment =

Article ID: 93674

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS

-



This article was previously published under Q93674



SYMPTOMS
In the interpreter environment, your program may hang causing the computer to quit responding if you have a Run statement in a procedure that also dimensions an array. This problem does not occur in programs compiled with the BC.EXE compiler.



STATUS
Microsoft has confirmed this to be a bug in the products listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
This problem occurs under the following conditions:


 * The Run statement is called with no parameters or with a line number in a procedure.
 * The procedure uses Dim or Redim to dimension an array local to that procedure.
 * The Sub or Function is not a static procedure.

The following example program reproduces the problem: ' Warning! This program causes the computer to hang (stop responding). Declare Sub sub1 sub1

Sub sub1 Dim y(1) y(1) = 1 Print y(1); ' Note: Using Erase on y before Run prevents hanging. Run End Sub You might use Run with no parameters or Run with a line number to restart a program. This form of Run completely reinitializes the program's environment -- closing files, reinitializing all static data, and de-allocating dynamic arrays.

Several workarounds to this problem are listed below:

  Use Erase on the dynamic arrays local to the Sub procedure just prior to using the Run statement. For example, if y is an array local to the Sub procedure, the following code works around the problem: Erase y     Run  If there is enough DGroup space, you can prevent the program from hanging by making the Sub procedure static. Make the array global by declaring it as Shared or Common Shared at the module level of the program. Pass the array as a parameter to the Sub procedure.

Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 7.00 7.10 buglist1.00 buglist4.00b buglist4.50 buglist7.00 buglist7.10

Keywords: KB93674

-

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

© Microsoft Corporation. All rights reserved.