Hi, can anyone tell me how to take a name entered in a text box and convert only the first letter of each name to upper and then convert the rest to lower.
Ex: "john doe" --> "John Doe"
"jAkE sMiTh" --> "Jake Smith"
Thanks.
Printable View
Hi, can anyone tell me how to take a name entered in a text box and convert only the first letter of each name to upper and then convert the rest to lower.
Ex: "john doe" --> "John Doe"
"jAkE sMiTh" --> "Jake Smith"
Thanks.
I think there is a simpilar way to do this but in the mean time here.
What i have done in this code is stored all the words into an array. Then by looping through the array the word is being split in two, the first part of the substring is the first letter. The first letter is then capitalized. After that is done the word is joined back together to make a whole. This process is done for every word in the array. As the process takes action the new edited word replaces the old word in the same array. The words from the array are being placed on a single line which will become the new value of Textbox1.
vb Code:
'Try something like so: Dim words() As String words = TextBox1.Text.Split(" "c) For x As Integer = 0 To words.Rank + 1 words(x) = (words(x).Substring(0, 1).ToUpper & words(x).Substring(1, words(x).Length - 1)) Next Dim NewString As String = String.Empty For i As Integer = 0 To words.Rank + 1 If i = 0 Then NewString = (words(i)) Else NewString = (NewString & " " & words(i)) End If Next TextBox1.Text = NewString
Thanks I'll give it a shot.
Try this;
Code:MyString = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(MyString)
lol, well there's putting it in one line. I guess i should remove the link i put in my signature...lolQuote:
Originally Posted by Bulldog