954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

specifying an input to a text box

hi.
can anyone here tell me how can i allow certain characters only into a text box.
for instance, a user can only input from these three letter (ABC)

thank you so much.

yeeitsneo
Newbie Poster
22 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
 

You can use key trapping by their corresponding ASCII equivalents and Case statements.

Example:

Private Sub Text1_KeyPress(KeyAscii As Integer)

Select Case KeyAscii

 Case 65 To 90, 8, 32, 39 ' A-Z and backspace and space Let these key codes pass through
 Case 97 To 122, 8 'a-z and backspace Let these key codes pass through
        
 Case Else
        
        KeyAscii = 0 ' Traps other characters
        
    End Select

Try to find the complete ASCII table. Would be useful. Cheers :)

abelingaw
Posting Whiz in Training
205 posts since Jun 2008
Reputation Points: 66
Solved Threads: 26
 

you forgot the enter :D
keyascii 13

Cruize_Invades
Light Poster
40 posts since May 2007
Reputation Points: 6
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: