I'd like to make my program run until the user exits with my exit command, and not the termination button. Is there anyway to trap that?
Printable View
I'd like to make my program run until the user exits with my exit command, and not the termination button. Is there anyway to trap that?
Hi,
There is one of two ways to do this:
First:
Second:Code:'Everytime they click the 'x' it cancels itself
Private Sub Form_Unload(Cancel As Integer)
Cancel = 1
End Sub
Set the ControlBox property of the form to False so that no 'x' is shown.
Hope this helps
Shaun
No! Don't do that :( You won't be able to ever close your prog!!!
Use
This'll work!Code:Public DontCancelMe As Boolean
Private Sub Form_QueryUnload(cancel as integer)
If DontCancelMe = False Then
'Exit via the X button, don't close
Cancel = 1
End If
'Else it's via your button, so close it!
End Sub
Private Sub ExitMe_Click
DontCancelMe = True
Unload Me
End Sub
[Edited by Jop on 09-08-2000 at 01:48 PM]
Hi Jop,
He did say that he has his own Exit command so that they would still be able to exit his App ;)
I think he meant his own way to exit (in a menu with extra confirmation).
And in your case (Form_Unload) you're not able to unload the prog in any way (yeah end maybe, but not in a proper way)
Not arguing with you :)
What's wrong with End anyway?
Hey, one thing, no hard feelings man! I'm serious, I'm not trying to be 'better' than you, end just does what it says, it just ends the prog without Unloading it from the memory, so it's not a good idea to just quit it leaving the resources unavailable for other progs. That's what the Unload is for, making sure the used resources are made free.
get it? (I ain't mad at ya :))
Are you two married? Just seemed there was a little arguing going on there. Thanks for the help though.
No arguing! ;)
Jop is right, I've always used End and didn't know any better.
No we were not arguing!! (:)) not in my humble opinion :)
No... I was not mad, I was just trying to prove that I was right :)
No but serious, no hard feelings right? (this is startin' to be a Chit-Chat topic, hey they should make a "Hey I hate you" and a "I'm sorry" forum :))
Hey, look at all the :) smileys, that means we are happy! ;)
[Edited by Jop on 09-08-2000 at 02:21 PM]