473,513 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Messagebox code:

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
1 2576
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1658
by: Kevin R | last post by:
I'm running the HelloWorldForm example from Microsoft to learn how to use ..net. I'm using Microsoft Visual Studio .NET 2003, 1.1 framework. I run the HelloWorldForm example. The example runs...
8
2433
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
4
1917
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
3
7410
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
20
8859
by: Peter E. Granger | last post by:
I'm having a strange problem (or at least it seems strange to me) trying to display a MessageBox in a VC++ .NET forms application. If I put the call to MessageBox::Show in the form's .h file, it...
5
1544
by: Curt Emich | last post by:
I always thought writing a simple diagnostic message in a message box would be pretty simple. Not in .NET. First, I wrote this amazingly complex piece of code: MessageBox.Show("yer mama") ...
10
2324
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
3
6489
by: VMI | last post by:
I know this isn't the best group to post aspnet question, but the MS asp.net NG hasn't been very helpful lately. I've been trying to add a messagebox following the examples I've seen on the web,...
3
4137
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and...
9
7942
by: sovht | last post by:
System: Intel, Windows XP Pro, SP2 IDE: VC++ 6.0 Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string. I checked the spec for the...
0
7161
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.