ucase on change

  • Thread starter Thread starter seeker
  • Start date Start date
S

seeker

I have a textbox that the user wants to have all caps while he types into the
textbox. The following code is in the onchange event for the textbox.

txtNameKey.Text = UCase(txtNameKey.Text)
txtNameKey.SelStart = Len(txtNameKey) + 1

This takes the textbox back to the first letter and overwrites it. I want
it to type the second letter and then third etc. Thanks.
 
seeker said:
I have a textbox that the user wants to have all caps while he types into
the
textbox. The following code is in the onchange event for the textbox.

txtNameKey.Text = UCase(txtNameKey.Text)
txtNameKey.SelStart = Len(txtNameKey) + 1

This takes the textbox back to the first letter and overwrites it. I want
it to type the second letter and then third etc. Thanks.


I don't think I'd use the Change event for this. How about using the
control's KeyPress event instead, to translate each keystroke as it is
typed:

'------ start of code ------
Private Sub txtNameKey_KeyPress(KeyAscii As Integer)

KeyAscii = Asc(UCase(Chr(KeyAscii)))

End Sub
'------ end of code ------
 
You could try this in the KeyPress event of the Text box :-

KeyAscii = Asc(UCase(Chr(KeyAscii)))

HTH

Peter Hibbs.
 
Back
Top