[英]Allow only one number in vb.net
Im new in programming and i want to ask for a help.我是编程新手,我想寻求帮助。 I'm asking for the code in vb.net where after i put period or "."
我要求在 vb.net 中输入句号或“。”之后的代码。 In the textbox I want the textbox to accept only number 5. The textbox will not accept any letters or numbers or special characters in my textbox after I put period or "."
在文本框中,我希望文本框仅接受数字 5。在我输入句点或“。”后,文本框将不接受文本框中的任何字母、数字或特殊字符。
This might help you:这可能会帮助您:
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If Trim(CType(sender, TextBox).Text).EndsWith(".") AndAlso (e.KeyData <> Keys.D5) Then
e.SuppressKeyPress = True
e.Handled = True
Console.WriteLine("Type another key. this is not number 5")
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.