The information in this article applies to:
SUMMARY
When using the UCase$ or LCase$ functions in Microsoft Visual Basic
for Windows to capitalize text or make text lower case from within the
change procedure of a text box, you may encounter unexpected results if
the following conditions are true:
MORE INFORMATIONWhen allowing users to enter text into text boxes, it is often desirable to control whether the user enters all uppercase or all lowercase letters. To do this, it would seem that putting a UCase$ or LCase$ statement in a text box Change event would allow you to enter only uppercase or lowercase letters into the text box. However, each time you press a key, the Change event fires and the cursor is brought back to the beginning of the text box as a result of assigning the Text property a new string. Steps to Reproduce Behavior
An alternative method of changing all contents of the text box to capital letters is to change the KeyAscii code of the typed information in the text box KeyPress event as follows:
When you run the above code, the letters typed into the text box are
immediately changed to capital letters and are entered correctly as
you type them in.Another alternative method of changing the contents of the text box to uppercase letters is to add the following code to the Change event for the text box:
SelStart sets or returns the starting point of text selected, and
indicates the position of the insertion point if no text is selected.
Additional query words: 2.00 3.00
Keywords : |
Last Reviewed: September 17, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |