掩码文本框中的浮点数 [英] float number in masked textbox
本文介绍了掩码文本框中的浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我有一个蒙面文本框并将其放入数字5位数。我在它的面具上写了一个漂浮号码为___.__!
但我的问题是如何将它作为浮点数检查?例如,我想如果我的入口号码高于102.00,请在消息框中显示错误。
浮动a;
如果(a> = = 102.00)
{
messagebox.showdialog(错误,);
}
-----------------------------
a是掩盖的值textbox!
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!
推荐答案
您可以使用TryParse尝试解析输入的值。这可以防止引发异常,也可以转换字符串中的值。查看此链接:
String textValue = TextBox1.Text; [ ^ ]
祝你好运!
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!
我可以使用如下:
i can use as following:
double f = Convert.ToDouble(maskedTextBox6.Text);
if (f > 102.00)
{
MessageBox.Show("Err", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
serialPort1.WriteLine(maskedTextBox6.Text);
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);
>
这篇关于掩码文本框中的浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文