Microsoft KB Archive/81469

= Task List Switch to VB Application Fails After ALT+F4 Close =

Article ID: 81469

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q81469



SUMMARY
Selecting the Close command from the Control menu (ALT+F4) to quit a Visual Basic application will not necessarily unload any other forms that have been loaded. If other forms have been loaded but are not visible, the application may still be running under Windows. If this is the case, the Windows Task List will still contain the name of the application. Attempting to switch to the application from the Windows Task List will be unsuccessful.

If you want the application to terminate as a result of unloading a particular form, place an End statement in the Form_Unload event procedure for the form, or use the Unload statement to unload all forms that are loaded. This will cause all forms (visible and invisible) to be unloaded, and the application to terminate.



MORE INFORMATION
Even if the form that is closed is the designated startup form in your application, it will not automatically unload previously loaded forms. Therefore, the application can in fact still be running and appear in the Windows Task List. You can terminate the application by selecting the End Task button in the Windows Task List, but you will not be able to switch to the task.

Below are the steps necessary to cause an application to terminate when a particular form is closed from the Control menu (ALT+F4).

With the application loaded in VB.EXE (the Visual Basic for Windows development environment), do the following:

 Double-click the form to open the Code window.  Add an End statement to the Form_Unload event procedure for the form. For example: Sub Form_Unload (Cancel As Integer)

' Your code goes here.

End ' This unloads all the forms and terminates the application.

End Sub 

Adding an End statement to the Unload event procedure of a form will not cause the Unload event procedures for the other forms to be called. To cause the Unload event procedures for the other forms to be called, use the Unload statement to explicitly unload each form.

Additional query words: 2.00 3.00

Keywords: KB81469

-

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

© Microsoft Corporation. All rights reserved.