By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,556 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,556 IT Pros & Developers. It's quick & easy.

Help With Code

P: n/a
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


Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

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

"Brian" <br***********@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
: 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
:
:
:
:


Nov 21 '05 #2

P: n/a
Thanks..I will give it a try..maybe the book had a typo..I am still a newbie
to have seen the problem...
"_AnonCoward" <ab*@xyz.com> wrote in message
news:Ih*******************@twister.southeast.rr.co m...

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

"Brian" <br***********@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP10.phx.gbl...
: 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
:
:
:
:

Nov 21 '05 #3

P: n/a
What errors are you getting?
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.