Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text inputs in lower case

Status
Not open for further replies.

skippypaul

Programmer
Nov 20, 2002
3
US
I am a VB beginner and trying to get a client name entering text box to only accept alphabetic inputs. The box accepts UpperCase (Capital) inputs (using &quot;KeyASCII >=A or KeyASCII <=Z), but I cannot work out how to get it to accept lower case. The same code with lower case letters does not work.
 
lowercase alpha characters

if keyascii>=97 and keyascii<=122 then

uppercase alpha characters

if keyascii>=65 and keyascii<=90 then
 
You may also want to allow backspace (keyascii = 8)
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
skippypaul

try this code...

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case UCase(Chr(KeyAscii))
Case &quot;A&quot; To &quot;Z&quot;, Chr(vbKeyBack), Chr(vbKeySpace) 'Allowed
Case Else
KeyAscii = 0
End Select
End Sub


hope i help you... [pipe]

Tholits
 
Also if you want to allow fullstops, comma's or punctuation ....

Transcend
[gorgeous]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top