Help With Code

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hi!

I've been cruising right along with Sams VB.NET book (24 Hour) and typed in
some code exactly as it should be and it is giving me errors..can anyone
help me troubleshoot it? It deals with the QUIT event but here is the entire
code:

Private Sub mnuQuit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuQuit.Click

If mnuAskBeforeClosing.Checked Then

MessageBox.Show("Do you wish to eixt?", "Menus", _

MessageBoxButtons.YesNo) = DialogResult.No Then

Exit Sub

End If

Me.Close()

End Sub

Private Sub mnuAskBeforeClosing_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuAskBeforeClosing.Click

mnuAskBeforeClosing.Checked = Not (mnuAskBeforeClosing.Checked)

End Sub
 
Your If statements aren't nested correctly. Try this:

If mnuAskBeforeClosing.Checked Then

'ADD AN IF HERE
If MessageBox.Show("Do you wish to eixt?", "Menus", _
MessageBoxButtons.YesNo) = DialogResult.No Then

Exit Sub

'AND CLOSE THE BLOCK HERE
End If
End If
Me.Close()
End Sub





: Hi!
:
: I've been cruising right along with Sams VB.NET book (24 Hour) and
: typed in some code exactly as it should be and it is giving me
: errors..can anyone help me troubleshoot it? It deals with the QUIT
event
: but here is the entire code:
:
: Private Sub mnuQuit_Click(ByVal sender As System.Object, ByVal e As
: System.EventArgs) Handles mnuQuit.Click
:
: If mnuAskBeforeClosing.Checked Then
:
: MessageBox.Show("Do you wish to eixt?", "Menus", _
:
: MessageBoxButtons.YesNo) = DialogResult.No Then
:
: Exit Sub
:
: End If
:
: Me.Close()
:
: End Sub
:
: Private Sub mnuAskBeforeClosing_Click(ByVal sender As System.Object,
: ByVal e As System.EventArgs) Handles mnuAskBeforeClosing.Click
:
: mnuAskBeforeClosing.Checked = Not (mnuAskBeforeClosing.Checked)
:
: End Sub
:
:
:
:
 
Thanks..I will give it a try..maybe the book had a typo..I am still a newbie
to have seen the problem...
 
Back
Top