Upper case the 1st letter of a word on the TextBox key press
-
Hiya, I hope that you can help. Does anybody know how to force the 1st letter of each word in a TextBox to upper case as the key is pressed? The idea is that a user would be able to enter a name or address etc and the 1st letters of each word would automatically be changed to a capital letter WITHOUT the user having to hold down the shift key. I was able to do this OK in VB6. I would just test the ascii value of the previous character that had been pressed. If the length of the string was zero OR the previous character was a space, I would just change the letter to upper case as shown below. KeyAscii = Asc(UCase(Chr(KeyAscii))) I know that the .Net TextBox has a CharacterCasing property but that just uppercases or lowercases all the characters. Thanx Rob
-
Hiya, I hope that you can help. Does anybody know how to force the 1st letter of each word in a TextBox to upper case as the key is pressed? The idea is that a user would be able to enter a name or address etc and the 1st letters of each word would automatically be changed to a capital letter WITHOUT the user having to hold down the shift key. I was able to do this OK in VB6. I would just test the ascii value of the previous character that had been pressed. If the length of the string was zero OR the previous character was a space, I would just change the letter to upper case as shown below. KeyAscii = Asc(UCase(Chr(KeyAscii))) I know that the .Net TextBox has a CharacterCasing property but that just uppercases or lowercases all the characters. Thanx Rob
well , i hope i can help in vb.net in the event :
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles PrixVerreDP.KeyPress
see that e i wrote over ?? this is the stuff you look for now write ascii = asc(e.keychar) to get the code ascii of the letter you typed i hope this helped you try to be good if you can't be the best -
well , i hope i can help in vb.net in the event :
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles PrixVerreDP.KeyPress
see that e i wrote over ?? this is the stuff you look for now write ascii = asc(e.keychar) to get the code ascii of the letter you typed i hope this helped you try to be good if you can't be the bestThanks for your lightning response. I was just surfing the web looking for an answer and found a suite of controls called ITTeamControls .Net. It extends the existing CharacterCasing property with a UpperFirst value. So there is no need for any coding. Think we might buy a few licences. The product landing page is http://www.itteam.net/itteamcontrols.html[^] Rob