Help With Code

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
 
A

_AnonCoward

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
:
:
:
:
 
B

Brian

Thanks..I will give it a try..maybe the book had a typo..I am still a newbie
to have seen the problem...
 

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