exit command

  • Thread starter enrico via DotNetMonster.com
  • Start date
E

enrico via DotNetMonster.com

i created an exitstrip tool on my system and i want my system to ask the user
if he/she really wants to exit the application. but when i add a command on
the forms close button my exitstrip tool doesn't work well. this is my
command on my exitstrip tool:

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
Flag = True
If MessageBox.Show("Do you really want to exit this application?", "",
MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
TextBox3.Focus()
End If
End Sub

and this is my command on my close button:

Private Sub Form3_FormClosing(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If MessageBox.Show("Do you really want to exit this application?", "",
MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub

is there something wrong on my codes?
 
K

kimiraikkonen

i created an exitstrip tool on my system and i want my system to ask the user
if he/she really wants to exit the application. but when i add a command on
the forms close button my exitstrip tool doesn't work well. this is my
command on my exitstrip tool:

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ExitToolStripMenuItem1.Click
Flag = True
If MessageBox.Show("Do you really want to exit this application?", "",
MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Me.Close()
Else
TextBox3.Focus()
End If
End Sub

and this is my command on my close button:

Private Sub Form3_FormClosing(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If MessageBox.Show("Do you really want to exit this application?", "",
MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
e.Cancel = True
End If
End Sub

is there something wrong on my codes?

Your code works fine without "Flag = True" code line. What's your
problem by calling "doesn't work" ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top