How to completely stop a VB 6 Application
I wrote a Visual Basic 6 program and included a command button to stop the program
Below is the code I used to stop the program
Private Sub cmdStop_Click()
Unload Me
End
End Sub
The program plays a short wav file every sixty seconds to let the user know it’s still running. Of course it does other stuff too.
I created an Executable and the command button works fine and completely stops the application. After I click the command button the program disappears from the Task Manage.
When I click the Red X in the upper right corner the window closes but the task continues running, it doesn’t disappear from the Task Manager and it continues playing the sound file every sixty seconds.
How do I force a clean completely close?
Thanks
Re: How to completely stop a VB 6 Application
Visit the FAQ section at this link. There are at least two topics there that will interest you
Re: How to completely stop a VB 6 Application
if you have a timer to play the waves, you should make it enabled = false
it is considered very bad practice to use end
Re: How to completely stop a VB 6 Application
Quote:
Originally Posted by
westconn1
if you have a timer to play the waves, you should make it enabled = false
it is considered very bad practice to use end
If you call the Unload event, doesn't that take care of cleanning up the various objects on the form, like the Timer control?
Also, I thought the controlbox at the upper right corner would fire the unload event.
Re: How to completely stop a VB 6 Application
Quote:
Originally Posted by
krtxmrtz
If you call the Unload event, doesn't that take care of cleanning up the various objects on the form, like the Timer control?
Not really... it will unload some things, but you need to stop the Timer control(s) yourself plus various other things, as explained by "How should I close my form/program/class?" FAQ article via LaVolpe's link.
Quote:
Also, I thought the controlbox at the upper right corner would fire the unload event.
It does indeed... which is why cmdStop should only contain Unload Me
The code to actually close the program (if needed) should be in the Unload event... as explained in the FAQ article I mentioned.