Click to See Complete Forum and Search --> : Memery!!
R Peate
March 21st, 2001, 07:51 AM
Can anybody suggest a good tool to find out what is responsable for a process that hangs around after application termination - my program does obviously not close eveything properly but i cannot find the source of the problem, any suggestions of tools would be greatful..
coolbiz
March 21st, 2001, 10:34 AM
Check if you're using Unload instead of End to end your program. Consider the following:
In Form1 (main form):
sub ShowForm2()
Form2.Show()
end sub
sub CloseForm1()
Unload me
end sub
In Form2:
sub cmdClose_Click()
me.Hide
end sub
So since Form2 is actually still in the memory (hidden object), you application does not really exit. But if you were to replace "Unload me" with "End", then you can assured that you application will be forced to exit.
Of course there are probably many other rootcauses but this is the one that I encountered when I first playing with VB.
-Cool Bizs
John G Duffy
March 21st, 2001, 12:46 PM
A good way to ensure that all processes are terminated is to unload all forms in the Form_Unload event of the terminating form like so.
private Sub Form_Unload(Cancel as Integer)
Dim f as Form
for Each f In Forms
If f.Name <> me.Name then
Debug.print f.Name
Unload f
End If
next f
End Sub
THis will give each form a chance to execute its individual Form_Unload event.
John G
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.