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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close properly an application 1

Status
Not open for further replies.

RSX02

Programmer
May 15, 2003
467
CA
I was using END but I read that it's not quite correct.
I need to close the task in the Task Manager.
Thanks in advance
 
If you use a MDI form, then this needs to be unloaded:
Unload myMDI

In the MDI's QueryUnload event, use a loop to unload all child forms:

Dim frm As VB.Form
For Each frm In VB.Forms
If Not TypeOf frm Is MDIForm Then
Unload frm
End If
Next frm

Then, make sure you also unload any designers (DataReport, Crystal Reports, etc) and Close/destroy any objects (Such as class objects, Connections, etc - also you need to explicitly close and destroy these in each form's Unload event, if they were declared at form module level)

If Not Conn Is Nothing Then
If Conn.State = adStateOpen Then Conn.Close
Set Conn = Nothing
End If

Once everything is Unloaded and Destroyed, then you should be OK.
 
Make sure you set you forms to nothing
set frm = nothing
after you unload it.

Also, if your project references activeX dlls or control projects that have forms, VB will not unload your app depending on a few different conditions (formloaded not but visible, etc..). I cant seem to find the MSDN article about it though....try a search if it sounds like your issue.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top