473,385 Members | 1,907 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,385 software developers and data experts.

MaskedTextBox error


I have a maskedtextbox (msktxtbxAmount)defined thus: Mask $#####.## and
msktxtbxAmount.ValidatingType = typeof(System.Decimal) with a PromptChar of =.

I have defined: decimal transAmount and the following event handler:

private void msktxtbxAmount_TypeValidationCompleted(object sender,
TypeValidationEventArgs e)
{
if (!e.IsValidInput)
{
MessageBox.Show("Invalid amount", "Error",
MessageBoxButtons.OK);
}
else
{
transAmount = (decimal)e.ReturnValue;
}
}

After data entry the text shows "$===35.00" yet I am showing the "Invalid
Amount" error message.

Can anyone point out where I have gone wrong?

Thanks

Nov 7 '08 #1
3 3169
OK, if I amend the TextMaskFormat property to ExcludePromptsAndLiterals' the
input is accepted. However if I input 135.00, what is returned is 13500.

So how do I get 135.00 to be returned?

"Paolo" wrote:
>
I have a maskedtextbox (msktxtbxAmount)defined thus: Mask $#####.## and
msktxtbxAmount.ValidatingType = typeof(System.Decimal) with a PromptChar of =.

I have defined: decimal transAmount and the following event handler:

private void msktxtbxAmount_TypeValidationCompleted(object sender,
TypeValidationEventArgs e)
{
if (!e.IsValidInput)
{
MessageBox.Show("Invalid amount", "Error",
MessageBoxButtons.OK);
}
else
{
transAmount = (decimal)e.ReturnValue;
}
}

After data entry the text shows "$===35.00" yet I am showing the "Invalid
Amount" error message.

Can anyone point out where I have gone wrong?

Thanks
Nov 7 '08 #2
Can you divide by 100?

"Paolo" wrote:
OK, if I amend the TextMaskFormat property to ExcludePromptsAndLiterals' the
input is accepted. However if I input 135.00, what is returned is 13500.

So how do I get 135.00 to be returned?

"Paolo" wrote:

I have a maskedtextbox (msktxtbxAmount)defined thus: Mask $#####.## and
msktxtbxAmount.ValidatingType = typeof(System.Decimal) with a PromptChar of =.

I have defined: decimal transAmount and the following event handler:

private void msktxtbxAmount_TypeValidationCompleted(object sender,
TypeValidationEventArgs e)
{
if (!e.IsValidInput)
{
MessageBox.Show("Invalid amount", "Error",
MessageBoxButtons.OK);
}
else
{
transAmount = (decimal)e.ReturnValue;
}
}

After data entry the text shows "$===35.00" yet I am showing the "Invalid
Amount" error message.

Can anyone point out where I have gone wrong?

Thanks
Nov 7 '08 #3
Yes, that appears to do the trick. Thanks - doh!!!

"jp2msft" wrote:
Can you divide by 100?

"Paolo" wrote:
OK, if I amend the TextMaskFormat property to ExcludePromptsAndLiterals' the
input is accepted. However if I input 135.00, what is returned is 13500.

So how do I get 135.00 to be returned?

"Paolo" wrote:
>
I have a maskedtextbox (msktxtbxAmount)defined thus: Mask $#####.## and
msktxtbxAmount.ValidatingType = typeof(System.Decimal) with a PromptChar of =.
>
I have defined: decimal transAmount and the following event handler:
>
private void msktxtbxAmount_TypeValidationCompleted(object sender,
TypeValidationEventArgs e)
{
if (!e.IsValidInput)
{
MessageBox.Show("Invalid amount", "Error",
MessageBoxButtons.OK);
}
else
{
transAmount = (decimal)e.ReturnValue;
}
}
>
After data entry the text shows "$===35.00" yet I am showing the "Invalid
Amount" error message.
>
Can anyone point out where I have gone wrong?
>
Thanks
>
Nov 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mauricio C Vidotto | last post by:
I have an application that use MaskedTextBox Control. This control has Mask property value 9999999.99 and I would like to add numeric values with 2 decimal places. However, if I set Text property...
0
by: dumbo | last post by:
I do not succeed to modify the content of a MaskedTextBox control whose Property "OutputText" is in binding with field of type text of one table in database a MDB. The control has been generated...
1
by: Matt | last post by:
I recently came across what I believe to be a peculiar bug with Mdi Children, and wanted to see if anyone else had experienced this before sending it in. The issue is as follows: I have a number...
2
by: Jaime Rios | last post by:
Hi, I'm using C# to create a printable form. The data is coming from a XML source that I load when the application starts. I have no problems loading the data, but I am having a hard time figuring...
1
by: Jazer | last post by:
Hi, I have a problem with MaskedtextBox. When I 'am trying to insert value 1.5 (single type) into MaskedTextBox, the value on it is shown as 15__,_. Mask is #90.9 The result should be ___1,5...
2
by: sklett | last post by:
Hi, I'm trying to define a mask for a MaskedTextBox and can't get it right. For 5 numbers, '00000' seems to be a valid mask and behaves correctly, but I know need a control that will take a...
1
by: Craig | last post by:
Hi, I have had a look on google groups for help on the MaskedTextBox and strings but every post I find seems to relate for formatting numbers. So, is it possible to set up a mask on the...
1
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
We have some dumb and lazy people here, so I need help. To fix the dumb part: We have placed MaskedTextBoxes on the forms so they will stop entering the information incorrectly. Now the lazy...
1
by: eljainc | last post by:
Hello, I am trying to utilize a MaskedTextBox control on my form. I would like the user to enter numbers only (i.e. 65000), I set the Mask property as 999999 and the PromptChar as space (it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
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
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,...
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...

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.