Pierre
Member
I am struggling with the following logic that lies behind an exit button for a Windows application, which purpose is to ask the user to confirm that he wants to exit the application before actually executing the exit:
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Exit the application
MessageBox.Show("Are you sure that you want to exit the application?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
If DialogResult.Cancel Then
MsgBox("Be more careful next time!")
ElseIf DialogResult.OK Then
Application.Exit()
End If
End Sub
Indeed, it appears that the ElseIf statement never gets executed.
Can somebody give me some hints as to where the problem is?
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Exit the application
MessageBox.Show("Are you sure that you want to exit the application?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
If DialogResult.Cancel Then
MsgBox("Be more careful next time!")
ElseIf DialogResult.OK Then
Application.Exit()
End If
End Sub
Indeed, it appears that the ElseIf statement never gets executed.
Can somebody give me some hints as to where the problem is?