Convert the 1st letter of each word to upper case

ADO DOT NET

Centurion
Joined
Dec 20, 2006
Messages
160
Hi,
I need a function that convert the first letter of each input word to upper case.
I have written this one:
Visual Basic:
    Private Function FirstWordUp(ByVal Input As String) As String
        FirstWordUp = Input.Substring(0, Input.IndexOf(" ")).ToUpper + Input.Substring(Input.IndexOf(" "), Input.Length - Input.IndexOf(" "))
    End Function
But however, this only converts the first letter of the first word to upper case.
The problem is that I usually become very confused when working with such string operations! :confused:
Is anyone able to help me to complete this function?
Any idea?
Thanks:)
 
Visual Basic:
Dim s As String = "test message thing"

s = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(s)

should do it for you - also is locale aware when it comes to handling what should and shouldn't be capitalised.
 
Thanks a lot, it was great! :)
Just one more question: I need both converting the first letter of each word to upper case and lower case.
This do the trick for uppercase, you know what should I do for lower case?
Thank you.
 
Back
Top