In my program, you can quit from a menu and the program asks you to make sure:

VB Code:
  1. Private Sub mnuexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuexit.Click
  2.         If MsgBox("Are you sure you want to end the program?", vbYesNo, "Exit CodeBook") = 6 Then
  3.             Application.Exit()
  4.         End If
  5.     End Sub
But pressing the 'x' button just closes the app straight away, how do I catch when the user uses either?

I know it has something to do with:
VB Code:
  1. Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
  2.  
  3.     End Sub
but I can't get it to work correctly. Any help would be appreciated.