John Cassell
Well-known member
- Joined
- Mar 20, 2007
- Messages
- 65
- Programming Experience
- Beginner
Hi There, can someone tell me what I am doing wrong here pls..
In 'My Project' settings, the shutdown mode is set to 'When last form closes'.
I have this code below to ask if you really want to quit. If I don't include the line 'application.exit' then the form disappears but the program is still running (in debug mode) but if I do include it, then it msgbox appears again after you have clicked Yes the first time.
Can anyone spot what I am doing wrong?
Thanks
John
In 'My Project' settings, the shutdown mode is set to 'When last form closes'.
I have this code below to ask if you really want to quit. If I don't include the line 'application.exit' then the form disappears but the program is still running (in debug mode) but if I do include it, then it msgbox appears again after you have clicked Yes the first time.
VB.NET:
Private Sub MainFrm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Try
Dim res = MessageBox.Show("Are you sure you want to close this window?", _
"Your application", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If res = vbYes Then
Log_In.TBL_UsersTableAdapter.LogOutUser(String.Empty, Current_UserLbl.Text)
Application.Exit()
Else
e.Cancel = True
End If
Catch ee As Exception
Throw ee
End Try
End Sub
Can anyone spot what I am doing wrong?
Thanks
John