[英]Check for decimal on masked textbox in VB.NET
I've got a masked textbox with the mask to be _____.__
. 我有一个蒙版文本框,其蒙版为
_____.__
。
Now someone can just put in 00001.__
. 现在有人可以只输入
00001.__
。 And it still works, but I need people to enter a decimal number. 它仍然有效,但是我需要人们输入一个十进制数字。 Also, how can I put a check on this?
另外,我该如何检查呢?
In an event like TextChanged
you can use: 在类似
TextChanged
的事件中,您可以使用:
if (maskedTextBox1.MaskCompleted == true)
{
// Invalid input
}
I believe it should be better just to convert the textbox to a decimal or double, since the lack of decimal numbers just means ".00". 我认为将文本框转换为十进制或双精度会更好,因为缺少十进制数字仅表示“ .00”。
So, you may: 因此,您可以:
So, if the user had informed a decimal number, you would have it; 因此,如果用户通知了十进制数字,则可以使用; otherwise your number will consider ".__" as ".00".
否则,您的电话号码会将“ .__”视为“ .00”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.