PDA

Click to See Complete Forum and Search --> : Loop keeps running after program is closed...


desquite
Jan 28th, 2000, 05:20 AM
I have a loop in my program to make it pause for a certain amount of time.

sngTime = Timer
Do While (Timer - sngTime) < 60
DoEvents
Loop

When I exit the program it still appears to be running in the task manager. How do I tell the program to stop all processes when it's closed? Or is there a way for me to check to see if the program has been closed? Then I can exit the Sub.

Thanks

[This message has been edited by desquite (edited 01-28-2000).]

Phobic
Jan 28th, 2000, 06:06 AM
One way to end:
Form_Unload(...)
End
End SubOr inside your loop...If Me.Visible = False Then End

The second example should only be used if your form is never otherwise hidden.

MartinLiss
Jan 28th, 2000, 06:34 AM
How do you exit the program? When you do exit, do you explicitly unload all forms? If you don't do the latter, it may be the cause of your problem.

------------------
Marty
COGITO EGGO SUM
I think; therefore I am a waffle.

Juan Carlos Rey
Jan 28th, 2000, 07:42 AM
I used to think. Now I'm just scrambled eggs!

desquite
Jan 30th, 2000, 09:23 PM
Here is what my unload sub looks like. It still seems to keep itself in memory though. I'm not sure what part of my program is still looping. Any ideas? Thanks.


Private Sub Form_Unload(Cancel As Integer)
Timer1.Enabled = False
Unload frmMain
Set frmMain = Nothing
End Sub

desquite
Jan 30th, 2000, 10:05 PM
Well, I got it to work. I just added an 'End' after the statements in my Unload sub.

Thanks everyone.