The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: How to Format a String in Proper Case or Title Case in VB.NET
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Jim StevensPosted Mar 28, 2011, 1:35 PM
Dim propercase as string = StrConv(SomeText, VbStrConv.ProperCase)
Adam DownsPosted Sep 1, 2010, 4:32 PM
To simplify Public Function ToProper(ByVal str As String) As String Dim newString As New StringBuilder For Each s As String In str.Split(" ") newString.Append(s.Substring(0, 1).ToUpper & s.Substring(1).ToLower + " ") Next Return newString.ToString.Trim End Function
RenatoPosted Aug 17, 2009, 2:58 AM
I wonder why you didn't use the StringBuilder. As you know, in .NET strings are immutable and when you write something like Dim a As String = "hello" a += " world" you created two distinct strings in your heap memory. One containing "hello" and another one containing "hello world" (plus the \0 char, of course). So, you're going to create N+1 distinct strings where N is the number of the characters in the starting one. :)