lowercase to uppercase ( automatic )

  • Thread starter Thread starter cho
  • Start date Start date
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.
 
On format property of the textbox type the symbol > and on before
update event of your form
Me.NameOfField=UCase(Me.NameOfField)
 
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.
 
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.
 
Back
Top