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.

Recommended Answers

All 2 Replies

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 :)

you forgot the enter :D
keyascii 13

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.