ID Number: Q81469
1.00
WINDOWS
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.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
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 development
environment), do the following:
1. Double-click on the form to open the Code window.
2. Add an End statement to the Form_Unload event procedure for the
form.
Sub Form_Unload (Cancel As Integer)
'your code goes here
'
End 'this will unload all forms and terminate 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.
You can prevent the user from closing a form from the Control menu by
setting the ControlBox property to False at design time.
Additional reference words: 1.00