hey need some help guys. for example i have a text box and i will have input in it. but only numeric ones are allowed to be inputted in the text box if a character for example "a" is pressed the text box will not change and type the "a" and if a numeric button for example is 1, the text box will have 1. how can i do this? thanks.
dc_24l
0
Newbie Poster
Recommended Answers
Jump to Posthi dc_241
try this
if keyascii>65 or keyascii<97
msgbox"error"
endif
Jump to PostYou don't have to lock the text box, just set KeyAscii to 0. Also, you need to handle the backspace key to allow users to fix errors:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57, 8
'Let these key codes pass through
Case Else
'All …
All 6 Replies
vivekPSG
0
Newbie Poster
Jx_Man
987
Nearly a Senior Poster
Featured Poster
SCBWV
47
Junior Poster
Jx_Man
commented:
Nice Recovery
+1
Jx_Man
987
Nearly a Senior Poster
Featured Poster
Neophyte08
0
Newbie Poster
KSS
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.