Hi guys,
The following code checks if any alphabets are entered in the textbox and display an error message if the user is typing any alphabet. I want to amend this so that no error message displays on the screen but if the user types alphabet then just ignore the alphabet (textbox must not accept any alphabet).
I hope it makes sense. Any help will be much appreciated.
Thanks
The following code checks if any alphabets are entered in the textbox and display an error message if the user is typing any alphabet. I want to amend this so that no error message displays on the screen but if the user types alphabet then just ignore the alphabet (textbox must not accept any alphabet).
Code:
Private Sub txtAccount1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If -CLng(Chr(KeyAscii) Like "[0-9]") = 0 Then MsgBox "Please Enter Numbers Only", vbCritical + vbOKOnly, "Account no validation"
KeyAscii = KeyAscii * -CLng(Chr(KeyAscii) Like "[0-9]")
End Sub
I hope it makes sense. Any help will be much appreciated.
Thanks