Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 app stuck in task manager/memory 4

Status
Not open for further replies.

JacobTechy

Programmer
Apr 14, 2005
181
US
vb6sp6 installed application stuck in task manager/memory after closing it and I cannot open it and of course it triggers the code I put in the form load function
Code:
If App.PrevInstance = True Then
 MsgBox "This program is already running!", vbExclamation
 Unload Me
 Exit Sub
End If

I close the application with an exit button or the X and then calling this function.

Code:
Public Sub EndProgram()

     Dim frm As Form
      
     For Each frm In Forms
          Unload frm
          Set frm = Nothing
     Next frm

End Sub

Any ideas what the problem could be?
 
Have you tried calling EndProgram from form_unload
 
The problem is that you're trying to unload a form from it's Form_Load event. A form can't be unloaded until it is fully loaded and that doesn't happen until Form_Load completes. The Unload is in fact generating another load of the form. Try moving your code to the Form_Activate event.
 
Is your program using any Office COM objects, such as the Excel library? Because a frequent problem is people not unloading the objects that Office components create on their behalf, resulting in programs that won't unload.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
No my program is not using any Office COM objects.

However, I have placed my unload form code and end program in the form unload and it worked!!

Thanks

 
END is always a bad thing. Use the Form_Activate event instead of Form_Load. This way, as soon as it's loaded, it will be unloaded. You can use me.Hide in the form load event if there is a flicker as it is loaded.

-David
2006 Microsoft Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top