"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote
How do I go about limiting a textbox to accepting numeric key input from
the keyboard in vb.net?
<URL:http://groups.google.d e/groups?selm=OFw 5dO1kEHA.2504%4 0TK2MSFTNGP14.p hx.gbl>
Would you really rather use an expensive error trap when you can include
the test yourself? Testing it with code does not induce the delay you get while
the error is being caught....
Dim Source As TextBox = DirectCast(send er, TextBox)
Dim Message As String
If Source.Text Like "*[!0-9.]*" Then ' Remove '.' if decimals are not allowed.
Message = "Text is not expected here." & vbCrLf & "Enter a numeric value."
End If
Me.ErrorProvide r1.SetError(Sou rce, Message)
???
LFS