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

Messagebox code:

P: n/a
A
Hi Folks

I am trying to make a messagebox work but am having no joy with my code
What i want to achieve is to perform a set of tasks if the yes button is clicked or run a diffent set of code if the no butoon is clicked. Can anyone tell me what i am doing wrong
This is the error i am getting

An unhandled exception of type 'System.ComponentModel.InvalidEnumArgumentExceptio n' occurred in system.windows.forms.dl
Additional information: Enum argument value 32 is not valid for buttons. buttons should be a value from DialogResult

Here is my code that i am trying

If MessageBox.Show("If you exit this form, you will lose your booking. Do you
wish to continue?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) = DialogResult.No The
'what to do if yes button is clicke
Els
'what to do if the no button is chose
End I

what am i doing wrong
Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try this:

If MsgBox("If you exit this form, you will lose your booking. Do you wish
continue?", _
MsgBoxStyle.YesNo + MsgBoxStyle.Question + MsgBoxStyle.DefaultButton1) =
MsgBoxResult.Yes Then
'what to do if yes button is clicked
Else
'what to do if the no button is chosen
End If

Hope this helps

Mark
"A" <an*******@discussions.microsoft.com> wrote in message
news:62**********************************@microsof t.com...
Hi Folks,

I am trying to make a messagebox work but am having no joy with my code.
What i want to achieve is to perform a set of tasks if the yes button is clicked or run a diffent set of code if the no butoon is clicked. Can anyone
tell me what i am doing wrong. This is the error i am getting:

An unhandled exception of type 'System.ComponentModel.InvalidEnumArgumentExceptio n' occurred in
system.windows.forms.dll Additional information: Enum argument value 32 is not valid for buttons. buttons should be a value from DialogResult.
Here is my code that i am trying:

If MessageBox.Show("If you exit this form, you will lose your booking. Do you wish to continue?", _
MessageBoxButtons.YesNo, MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button1) = DialogResult.No Then 'what to do if yes button is clicked
Else
'what to do if the no button is chosen
End If

what am i doing wrong?

Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.