To automatically convert uppercase and lowercase letters, the first thing many people think of must be UCase$ and LCase$. However, if you want to use these two functions, you must not use them in the Key_PRess event. Otherwise, if you enter "ABC", the result will become "cba" 》, why?
Because when you enter A, LCase$ will convert it to a for you, but after the conversion is completed, the mouse cursor will stop in front of a. If you continue to enter B, it will become Ba, and LCase$ will convert it to ba for you. , after the conversion is completed, the mouse cursor stops in front of ba. You continue to enter C and it becomes Cba. LCase$ converts it to cba for you! If you don’t believe it, try it yourself
The correct approach in Key_Press is to determine its parameter KeyAscii! The Asc value of a is 97, and the Asc value of A is 65, so it is necessary to automatically convert uppercase to lowercase. The writing method is as follows:
PrivateSubText2_KeyPress(KeyAsciiAsInteger)
IfKeyAscii>=65AndKeyAscii<=90Then
KeyAscii=KeyAscii 32
EndIf->