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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a txt box to only accept uppercase.

Status
Not open for further replies.

Neozero

MIS
Jul 7, 2000
49
0
0
US
I am trying to make a txt box all uppercase. So if someone puts in lowercase, it will convert it to uppercase and if uppercase is put it, it will just take it. I am not real familliar with writing vb script, so that is why I am asking.
 
Try Thread222-515700

I think there is an API solution that takes care of upper casing the data whether the user types the data in or copy and pastes the data. There are other solutions posted there are well.

Swi
 
Since you posted this to a Visual Basic forum but you say you don't know VBScript well, the first thing is to determine what your actual language is. Are you doing this in Visual Basic, Visual Basic for Applications, or VBScript?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Try this in the textbox's LOSTFOCUS property

TEXT1 -the box that has the input we want Uppercase

Code:
 text1.text=format(text1,">")

> (this denotes UPPERCASE)
< (LOWERCASE)
or investigate the LCASE/UCASE statements
i believe the format is:
Code:
text1.text=UCASE(text1.text)
Again, i would put this code in the controls LOSTFOCUS property. I have used FORMAT for most of my apps. such as:
Code:
txtPhoneNumber_LostFocus()

txtPhoneNumber=Format(txtPhoneNumber,"(###)###-####")
End Sub

Notice*** the above FORMAT should be together not on separate lines! It just posted that way!

Hope that answers your question! ;)


LoL Concepts®
 

Hi Neozero,
In the textbox_KeyPress event write the code
KeyAscii = Asc(UCase(Chr(KeyAscii)))

Madhivanan
 
Neozero
Try thread222-515700. It suggests code utilizing APIs. You will avoid clattering your Lost Focus, Key Press and Key Down events with UCase or similar functions.

vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top