Microsoft KB Archive/189812

= BUG: Unloading a Modal Form's Parent Form Causes VB To Hang =

Article ID: 189812

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q189812



SYMPTOMS
In Visual Basic, if one form shows another form modally, and the second form tries to unload the first form in either its Unload or Query_Unload event, Visual Basic hangs.



CAUSE
When unloading a modal form's parent form, Visual Basic enters an infinite loop.



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



Steps to Reproduce Behavior
 Create a new Standard EXE project in Visual Basic. Form1 is created by default. Add a new form (Form2) to the project.  Add a CommandButton (Command1) to Form1 and add the following code to the Click Event: Private Sub Command1_Click Form2.Show vbModal End Sub

  Add a CommandButton (Command1) to Form2 and add the following code to Form2's code window: Private Sub Command1_Click Unload Me     End Sub

Private Sub Form_Unload(Cancel As Integer) Unload Form1 End Sub

 Save and run the project. On Form1, click on Command1 to show Form2 modally.</li> On Form2, click on Command1 to unload Form2, which unloads Form1 in its Unload event. Note that Visual Basic hangs. Use Task Manager to stop the non-responding application.</li></ol>

Additional query words: kbDSupport kbForm kbVBp500bug kbVBp kbdss kbVBp600bug

Keywords: kbbug KB189812

-

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

© Microsoft Corporation. All rights reserved.