Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a masked textbox and put it in numeric 5digits. i've writen float number on its mask as ___.__!
but my problem is how can i check it as a float number? for example, i want if my entrance number is higher than 102.00, show me an error, in a message box.

float a;
if(a>=102.00)
{
messagebox.showdialog("Error","");
}
-----------------------------
"a" is the value of in masked textbox!
Posted

You can use TryParse to try and parse the entered value. This prevents exceptions to be raised and will also convert the value from string. Check out this link:
String textValue = TextBox1.Text;[^]

Good luck!
 
Share this answer
 
Comments
mohsenvasefi 14-Oct-13 4:53am    
i have a button. if pressed it, the value in masked textbox(as float number) must be compare with a constant value(like 102.00). if condition is true, do!
it can't compare the value on masked textbox by 102.00! :(
i can use as following:
C#
double f = Convert.ToDouble(maskedTextBox6.Text);
            if (f > 102.00)
            {
            MessageBox.Show("Err", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            serialPort1.WriteLine(maskedTextBox6.Text);
 
Share this answer
 
Comments
BillWoodruff 14-Oct-13 7:40am    
If this not a "solution," but a progress report, then please add this to your original question. However, if you believe this does solve your problem, then fine.
SQL
i can use as following:
Collapse | Copy Code

double f = Convert.ToDouble(maskedTextBox6.Text);
            if (f > 102.00)
            {
            MessageBox.Show("Err", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            serialPort1.WriteLine(maskedTextBox6.Text);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900