Hi. I'm triing to do my own textbox that would allow only numeric characters to be displayed (and it will allso allow . and ,).
So. I can prevent this characters to be pressed? how can I do it?
I wrote some code, but I don't think it will go this way.
thank you a lot
So. I can prevent this characters to be pressed? how can I do it?
I wrote some code, but I don't think it will go this way.
thank you a lot
Visual Basic:
Private Sub myTextBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
'if not pressed a key between 0 and 9 or , or .
If Not (e.KeyValue >= 96 And e.KeyValue <= 105) Or e.KeyValue = 190 Or e.KeyValue = 188 Then
'how can I erase pressed key? or is there better way of doing it?
End If
End Sub