Convert a text content into Title Case in Vb.Net

Ranjeet_8
Posted by Ranjeet_8 under VB.NET category on | Points: 40 | Views : 1308
Convert a text content into Title Case in Vb.Net
Write this code on .Aspx.Vb (Page_Load)

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim strToConvertTCase As String = "The QUICK brown foX jumPs over the laZy doG"
' if the string with upper case will not be converted, in this case we should convert all text to lower case.
Dim strToConvertTCaseL As String = strToConvertTCase.ToLower()
Dim CultureInfo As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
Dim CultureTxtInfo As System.Globalization.TextInfo = CultureInfo.TextInfo
Response.Write("Input string:- " & strToConvertTCase & "<br />")
Response.Write("Title case string:- " & CultureTxtInfo.ToTitleCase(strToConvertTCaseL))
End Sub

OUTPUT will be:
Input string:- The QUICK brown foX jumPs over the laZy doG
Title case string:- The Quick Brown Fox Jumps Over The Lazy Dog

Comments or Responses

Login to post response