Unload an application's forms in reverse order of creation
This example shows how to unload an application's forms in reverse order of creation in Visual Basic 6.
close, unload, form
Software Engineering, Controls
Click the New button to make a new instance of the program's form. Click the Close All button to run the following code, which loops through the Forms collection unloading the forms, most recently created first.
Private Sub cmdCloseAll_Click()
Do While Forms.Count > 0
Unload Forms(Forms.Count - 1)
This example gets stuck in an infinite loop if one of the forms fails to unload.