VB Code:
  1. Private Sub frmInventory_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
  2.         Dim yesToUpdate As Integer
  3.  
  4.         If changes Then
  5.             yesToUpdate = MsgBox("Changes made are not save, do you want to save the changes ?", MsgBoxStyle.DefaultButton1 + MsgBoxStyle.YesNoCancel, "Save Changes")
  6.             If yesToUpdate = vbYes Then
  7.                 MsgBox("update")
  8.             ElseIf yesToUpdate = vbCancel Then
  9.                 MsgBox("Close the msgbox,but not close the form")
  10.             End If
  11.  
  12.             changes = False
  13.         End If
  14.         cnn.Close()
  15.     End Sub

What I want is if I click the "Cancel" button of he message box, I dont want the form to be closed. Only "Yes" and "No" will close the form.

Any idea how to achieve that?