PDA

View Full Version : Solved: Loading and unloading forms



zagrijs
01-21-2013, 04:53 AM
:hi:

Where is the best place to put a "Load Form"? The app's "Auto_Open" event?

And "Unload Form"? In the app's "Auto_Close" or somewhere else?

Does a form automaticaly unload when Excel is closed?

snb
01-21-2013, 07:54 AM
Whenever you need it.

in Excel e.g.


Private Sub Workbook_open()
userform1.show
end sub


and
Whenever you don't need the userform anymore


Private Sub Workbook_BeforeClose(Cancel As Boolean)
unload Userform1
End Sub

Paul_Hossler
01-21-2013, 01:10 PM
Since Load UserForm allocates memory to hold it, I only Load a UF when I will need it, and Unload it when I'm through with it.

Excel's garbage collection is pretty good, so when Excel closes, all the allocated memory is released

Paul

zagrijs
01-24-2013, 01:32 AM
Thanks for both replies. I understand.