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

ID: Q81469


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


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:

  1. Double-click the form to open the Code window.


  2. 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 :
Version :
Platform :
Issue type :


Last Reviewed: September 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.