AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

Unloading all Forms

How do you close your Visual Basic program?  Do you use the End method?  In this tip I will explain why using the End method is not the best way to close your program.  It is an undocumented fact that using the End method does not completely remove all forms from memory.  This means that your program does not give up all resources to other processes when it is closed using the end method.  The only way to completely shut down the program is to unload each of the forms using the Unload method.   Here is some code that loops through all loaded forms and unloads them one by one.   As soon as no forms are loaded, your program has been closed.

Public Sub UnloadAllForms()
Dim Form As Form
   For Each Form In Forms
      Unload Form
      Set Form = Nothing
   Next Form
End Sub      

It is best to call this procedure from the unload event of your main form.

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/