Matthew, that'll not work if the user backspaces, spaces or use the arrow buttons.
Use this instead:
It's pretty easy too!Code:Private Sub Text1_KeyPress(KeyAscii As Integer) '1 to 32 are system keys (del, space, tab, ctrl + V/C/Z, etc.) If KeyAscii < 33 Then Exit Sub If Not (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0 End Sub




Reply With Quote