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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel Close

Status
Not open for further replies.

WJProctor

Programmer
Jun 20, 2003
151
0
0
GB
HI there, on a form closing sub i have a msgbox asking if you want to close the form. If i click No how can i stop the form from closing its self? Is there a simple way, in 6 you used to be able to do a cancel or something.

Regards

JP
 
There is a boolean in the "e" event arguments that is usually named "Cancel"

e.Cancel = True

Set this to True, I believe. I am doing it from memory. You should check help on this.

That will keep the form open.

Ken

 
It works, I use it all the time.


Becca

Somtimes, the easy answer is the hardest to find. :)
 
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If (MessageBox.Show("Do You Wish To Exit", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = DialogResult.No) Then
e.Cancel = True 'Do not close form
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top