lowercase to uppercase ( automatic )

C

cho

Hi All,
How to control input data to a text field so that when its typed in lower
case,
VB will automatically convert it to uppercase.
 
S

Svetlana

On format property of the textbox type the symbol > and on before
update event of your form
Me.NameOfField=UCase(Me.NameOfField)
 
P

Peter Hibbs

Cho

You could just enter > in the Format property of the text box.

However, if you always want to have upper case in this field it looks
a bit messy because it only converts the text to upper case after the
user leaves the field and if they move the cursor back to the field
the text reverts to lower case again.

A better method is to enter the following code in the On Key Press
event of the text box. This converts the text to upper case as the
user enters the text.

Private Sub YourTextBoxName_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Peter Hibbs.
 
C

cho

Thnak's All,
It works.

Peter Hibbs said:
Cho

You could just enter > in the Format property of the text box.

However, if you always want to have upper case in this field it looks
a bit messy because it only converts the text to upper case after the
user leaves the field and if they move the cursor back to the field
the text reverts to lower case again.

A better method is to enter the following code in the On Key Press
event of the text box. This converts the text to upper case as the
user enters the text.

Private Sub YourTextBoxName_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Peter Hibbs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top