Right now if a user closes the form (either by clicking 'X' or chosing exit from a menu option) and changes are detected in the form, a messagebox will display asking the user if they would like to save any changes. The user has the option of clicking "yes, no or cancel." The problem I am having is with the cancel button. Every variation I've tried is still causing the form to close, even if cancelled is clicked. How can clicking cancel, essentially do nothing and go back to the form?
Private Sub PFC_XPRESS_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Result As DialogResult
If saved = False Then
Result = MessageBox.Show("Would you like to save changes?", "Confirm Exit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
ElseIf Result = Windows.Forms.DialogResult.No Then
Application.Exit()
Elseif Result = Windows.Forms.DialogResult.Cancel Then
'Do Nothing
ElseIf Result = Windows.Forms.DialogResult.Yes Then
Call Savefiledialog()
End If