Messagebox code:

G

Guest

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.InvalidEnumArgumentException' 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
 
M

Mark Hammond

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 said:
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.InvalidEnumArgumentException' occurred in
system.windows.forms.dll
Additional information: Enum argument value 32 is not valid for buttons.
buttons should be a value from DialogResult.
 

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