VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Allow UPPER-CASE only in a Text Box

by Acable (1 Submission)
Category: String Manipulation
Compatability: VB Script
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

Easy trick to allow only text and converts it to upper-case. (Backspace is optional)

Rate Allow UPPER-CASE only in a Text Box

Private Sub Text1_KeyPress(KeyAscii As Integer)
  Select Case KeyAscii
    Case 8
      'Delete this line and backspace will not be allowed
    Case 65 To 90
      'UPPER-CASE is allowed, do nothing here
    Case 97 To 122
      'This is lower case. By turning off Bit-5 lower-case will converted to UPPER-CASE
      KeyAscii = KeyAscii Xor 32
    Case Else
      'Other keys are not allowed. Set KeyAscii to 0 and nothing will be printed.
      KeyAscii = 0
  End Select
End Sub

Download this snippet    Add to My Saved Code

Allow UPPER-CASE only in a Text Box Comments

No comments have been posted about Allow UPPER-CASE only in a Text Box. Why not be the first to post a comment about Allow UPPER-CASE only in a Text Box.

Post your comment

Subject:
Message:
0/1000 characters