Binglee2323 Binglee2323 - 1 year ago 113 Question

Confirming program close with a messagebox

I have a message box that pops up when i press a close button that basicaly says" Are you sure you want to quit" but when i click the no button or cancel but the program closes any how

this is my code:

'Close Button
Private Sub BtnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClose.Click

Dim result = MessageBox.Show(" Are you sure you want to quit", "Are you sure?", MessageBoxButtons.YesNoCancel)

End Sub

Answer Source

You are doing nothing with the value of result. You need to inspect the value and determine whether you call Me.Close(). Code approximately

If result = DialogResult.Yes Then
End If
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download