If there are multiple characters in the textbox, there is no problem to use backspace. But if there is only one character left in the textbox, it pops up Run-time error 5 when entering backspace key. The main problem is if user enter first invalid character, he/she should be allowed to use backspace key.
Private Sub TextBoxABC_Change()
With TextBoxABC
If Right(.Text, 1) = " " Or (Asc(Right(.Text, 1)) < 48 Or Asc(Right(.Text, 1)) > 57) Then
MsgBox "Only numeric character allowed.", vbExclamation + vbOK
.Text = Trim(.Text)
End If
End With
End Sub
Backspace.JPG
Bookmarks