-
April 12th, 2010, 06:34 PM
#1
Creating a method for error messageboxes
I am building a pretty in depth wage calculator for class and I have to display a message box whenever a user's cumulative input for one days hours exceeds 24. In this phase of the project the professor wants me to encapsulate these error messages into a method to be called from the locations where I originally had these messages coded. I'm not sure how to proceed here. An example of my message is as follows:
if (dblTotalMon > 24)
{
MessageBox.Show (
"There are only 24 hours in a day! Please re-enter your hours.",
"Input Error", MessageBoxButtons.Ok,
MessageBoxIcon.Exclamation);
}
I have a lot of these messages and need to put them in a method within my form.
Any suggestions are welcome!
-
April 12th, 2010, 07:03 PM
#2
Re: Creating a method for error messageboxes
Ok... so, you have to essentially write a wrapper for the existing method MessageBox.Show( )?
Code:
void ShowError( string errMsg, string caption )
{
MessageBox.Show( errMsg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error );
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|