dcsimg
October 22, 2018
Hot Topics:

VB Coding Tip: Unload a Program Releasing All Memory

  • October 20, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

When you first start to program, memory management is not really an issue. But as you build larger and more powerful programs that are going to be used by more people, you will soon realise that your program needs to use the least amount of memory as possible, and, as a must, release it all after if finishes. This tip loops through the forms in your project unloading them. You might also want to consider setting your objects to nothing. E.g. Set db = Nothing

Private Sub Form_Unload(Cancel As Integer) 
Dim intCount As Integer 
While Forms.Count > 1 
'// Find first form besides "me" to unload 
intCount = 0 

While Forms(intCount).Caption = Me.Caption 
intCount = intCount + 1 
Wend 

Unload Forms(intCount) 
Wend 

'// Last thing to be done... 
Unload Me 
End 
End Sub 





Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

Thanks for your registration, follow us on our social networks to keep up-to-date