473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2575
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
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.