Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim NumbersAccepted As String = "0123456789" 'or the numbers you want to use
If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
)If NumbersAccepted.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
Thans btw Private Function ValidateNumeric(ByVal strText As String) _
As Boolean
ValidateNumeric = CBool(strText = "" _
Or strText = "-" _
Or strText = "-." _
Or strText = "." _
Or IsNumeric(strText))
End Function
If Not ValidateNumeric(TextBox1.Text) Then code here end if