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!

How do you EXIT VB6 without Task Manager showing App running????

Status
Not open for further replies.

mb22

Programmer
Sep 4, 2002
258
US
Sometimes when I exit my VB6 app... sometimes it still shows as running in the task bar. I unload all forms with a loop when exiting.
However when I try to Set Forms=Nothing in the loop.... sometimes it gives me errors.....so i commented that portion out.... here is the code for the loop in the Form/Unload event.

Dim iClearAll As Integer
'loop thru the forms collection and unload each form

For iClearAll = 0 To Forms.Count - 1
Unload Forms(iClearAll)
'Set Forms(iClearAll) = Nothing
Next

How do I make sure that all processes are terminated when I exit... and sample code?
 
do you have the statement "End" some where in the part where the app is closed? You do have the loop part right. End is the ungraceful way to unload an app.

Thanks,
James
[shadeshappy] [evil]
 
You have left a form open somewhere...

What I suggest you do is put a breakpoint on each form_Load event. Then run your program and see if it accidentally opens a form it shouldn't.

I will often have it where I copy common code for different forms in a BAS module, but miss changing the name and it therefore opens the other form without displaying it.

For instance if you had OK Buttons on each form and when the form is opened you wanted to disable them, or you wanted to clear text boxes. You might have in a BAS module.

Public Sub Initialize_Form1()
Form1.Text1.Text = ""
Form1.Text2.Text = ""
Form1.Text3.Text = ""
Form1.Text4.Text = ""

Form1.cmdOK.Enabled = False
End Sub

Public Sub Initialize_Form2()
Form2.Text1.Text = ""
Form2.Text2.Text = ""
Form2.Text3.Text = ""
Form2.Text4.Text = ""

Form1.cmdOK.Enabled = False
End Sub
[/tt]

As in the second example you set Form1's cmdOK to disabled. You may not notice in running, but Form1 is now open just not showing.


Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
The problem might reside with your PC. Where I work we have several PC's in our training room that no matter what you do in the VB application it would never leave memory. I could run an application and close it down and try to run again and it would tell me that application is already running. It was not limited to VB we had an application written in PowerBuilder and it did the same thing on the training PC. The PC's in question was running Windows NT.
 
That might have something to do with your user settings / permissions.

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
You might have it running twice.
Always use this in the first bit of code you run:-
If App.PrevInstance = True Then
MsgBox "You already have a copy running!", 16, ""
End
End If
Then you can never have 2 copies in the one computer
 
Few comments, The end statement should not be used, but if it is my understanding is that the process will be terminated, this would imply the End statement is not being executed. The form unload routine you have implemented wont work. As you unload forms the collection count/index reduces and you get a subscript out of range error. Use this code to unload all forms

Dim frm As Form

For Each frm In Forms
Unload frm
Next

Hope this helps
 

Could also be something simple like a DataReport being left open, a circular reference, or an object created at module/class level using the NEW keyword causing an object to get hung up when unloading the form improperly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top