Hi,
While testing just found out about commas or periods as decimals separator ...
to overcome this issue too ...
Private Sub TextBox1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8 To 10, 13, 27, 32 'Control characters
Case 44, 46 'comma, dot
If InStr(TextBox1.Text, ",") = 0 Then
KeyAscii = 44
Else
KeyAscii = 0
End If
Case 45 'minus
If TextBox1.SelStart = 0 And InStr(TextBox1.Text, "-") = 0 Then
Else
KeyAscii = 0
End If
Case 48 To 57 'numbers
Case Else 'Discard anything else
KeyAscii = 0
End Select
End Sub
HTH
Carim
Bookmarks