Changing letter casing
-
:(( I am using VB.NET and I have tried to find how to format a textbox to automatically change the first letter into a uppercase when someone types in the textbox. For example, I start typing in, food, when the first letter isnt capitalized I want it to automatically convert that first letter to uppercase, Food. Can anyone help? :confused: Tonnie
-
:(( I am using VB.NET and I have tried to find how to format a textbox to automatically change the first letter into a uppercase when someone types in the textbox. For example, I start typing in, food, when the first letter isnt capitalized I want it to automatically convert that first letter to uppercase, Food. Can anyone help? :confused: Tonnie
How about setting up a TextChanged event handler and doing a test, if the text starts with a lower case letter then change it. --Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
-
How about setting up a TextChanged event handler and doing a test, if the text starts with a lower case letter then change it. --Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
-
My problem is how to test it, what code or codes do I use to test it, so it will automatically change the first char to an upper.
I see a couple of ways. 1. Don't bother with a test and just do it this way:
s = s.Substring(0,1).ToUpper() + s.Substring(1);
You may need to test the length and conditionally omit the
+ s.Substring(1)
2. Get the first character, cast it to a number and test the range. You'll need to find an ASCII table, because I can't remember the codes. Option 1 may be better as the ToUpper() and ToLower() methods are culturally aware - If you have accented characters like áéíóú it will get them too, whereas with option 2 you need to find all possibilities yourself. --Colin Mackay--"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
-
I see a couple of ways. 1. Don't bother with a test and just do it this way:
s = s.Substring(0,1).ToUpper() + s.Substring(1);
You may need to test the length and conditionally omit the
+ s.Substring(1)
2. Get the first character, cast it to a number and test the range. You'll need to find an ASCII table, because I can't remember the codes. Option 1 may be better as the ToUpper() and ToLower() methods are culturally aware - If you have accented characters like áéíóú it will get them too, whereas with option 2 you need to find all possibilities yourself. --Colin Mackay--"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
-
This is great, only one small problem, I dont know how to create substrings to work correctly, any ideas?
Emmmmm... I have no idea what you mean.... You have a string you call the substring method on it and Robert is your father's brother. --Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)