title: Close Application with FormClosing Event VB.net
body: <p>I try to exit my application with form closing event but confirmation message box appears twice.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>Private Sub FrmMainPlatform_FormClosing(sender As Object, e As FormClosingEventArgs) _
   Handles MyClass.FormClosing
  
      Dim result As Integer
      result = MessageBox.Show("Are you want to close", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.None)
      If (result = DialogResult.No) Then
          e.Cancel = True
      Else
          Application.Exit()
      End If
  
  End Sub
  </code></pre>
  
  <p>I also tried with this solution: </p>
  
  <pre><code>Private Sub FrmMainPlatform_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  Select Case MessageBox.Show("Are you sure you want to exit?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
      Case Windows.Forms.DialogResult.Yes
          'nothing to do here the form is already closing
      Case Windows.Forms.DialogResult.No
          e.Cancel = True 'cancel the form closing event
          'minimize to tray/hide etc here 
      End Select
  End Sub
  </code></pre>
  
  <p>The form is closed but the application i still running.</p>