Stopping a form closing using vb.net

Quick and useful tip..

 

Private Sub MyForm_Closing(ByVal sender As System.Object, ByVal e As _
            System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
   Select Case MessageBox.Show(“Are you sure you want to close this window?”, _
      “Your application”, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    Case MsgBoxResult.Yes
     ‘Do Nothing
    Case MsgBoxResult.No
     e.Cancel = True
   End Select
Catch ee As Exception
  Throw ee
End Try
End Sub