Stop a from form closing

Hello,

I'm creating a editor, like notepad.

But i've this problem.

I don't know how to stop the program from closing.

Here is a code i would like to use:

Code:

Dim msgResult As MsgBoxResult

Private Sub Form1_Closing(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Closing

msgResult = MsgBox("Do you want to save the document?", MsgBoxStyle.Information + MsgBoxStyle.YesNoCancel, "Question")

If msgResult = MsgBoxResult.Cancel Then

'Stop's the form from closing code

ElseIf msgResult = MsgBoxResult.Yes Then

'Save code

End If

End Sub

I want the code for stopping the form from closing.

Greetings CPS

[1681 byte] By [Aidiakapi] at [2008-2-4]
# 1

this method have a parameter "e" is a system.EventArgs object and this object have a properti like "Cancel" just set this properti to "True"

e.Cancel=True

when de method if finished the from stop to close.

jprat at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,Visual Basic Express Orcas...

Visual Studio Orcas

Site Classified