ADO DOT NET Posted November 22, 2007 Posted November 22, 2007 Hi, I need a function that convert the first letter of each input word to upper case. I have written this one: 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:) Quote
Administrators PlausiblyDamp Posted November 22, 2007 Administrators Posted November 22, 2007 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted November 22, 2007 Author Posted November 22, 2007 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.