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 "." 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 "."
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.