[RESOLVED] Using vbNo and vbYes
How would I change it so that if a person clicked no, nothing happens?
Code:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (e.CloseReason = CloseReason.UserClosing) Then
MsgBox("Are you sure?", vbYesNo + vbQuestion, "Confirm")
If vbYes Then
Close()
If vbNo Then
End If
End If
End If
End Sub
End Class
Re: [RESOLVED] Using vbNo and vbYes
First, Msgbox() is not the proper format you'd use to do this. You would use Messagebox.show(), which has more power and manipulation than Msgbox(), which is just a wrapper.
Messagebox.show() is what you'd like to use to control YesNo operations, don't use old legacy vb code in a vb.net application.
Re: [RESOLVED] Using vbNo and vbYes
To sum up what the others are saying with an example:
Code:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If (e.CloseReason = CloseReason.UserClosing) Then
If MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
e.Cancel = True
End If
End If
End Sub