-
Sep 1st, 2010, 11:55 AM
#1
Thread Starter
New Member
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
-
Sep 1st, 2010, 12:06 PM
#2
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
-
Sep 2nd, 2010, 03:20 AM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Sep 2nd, 2010, 05:01 AM
#4
Re: How to completely stop a VB 6 Application
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.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 2nd, 2010, 09:20 AM
#5
Re: How to completely stop a VB 6 Application
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.
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|