Converting Strings To Title Case

Converting Strings To Title Case

I’ll present this tip the VB3 way and the VB4 way. I beat myself fora couple of hours over this routine to convert a string to Title Case.I used this with VB3:

 Function TCase(StrInp As String)Dim strout$Dim x%StrInp$ = LCase$(StrInp$)strout$ = UCase$(Left(StrInp$, 1))For x% = 2 To Len(StrInp$)	Select Case Asc(Mid$(StrInp$, x, 1))		Case Is < 97, Is > 122			strout$ = strout$ & Mid$(StrInp$, x, 1)		Case 97 To 122			Select Case Asc(Mid$(StrInp$, x - 1, 1))		Case 97 To 122			strout$ = strout$ & _				Mid$(StrInp$, x, 1)		Case Else: strout$ = _			strout$ & UCase$(Mid$(StrInp$, x, 1))	End SelectEnd SelectNextTCase = strout$End Function

In VB4, one line replaces the whole function:

 StrConv(string, vbProperCase)'Where vbProperCase is a built in constant in VB4
See also - an AI reverse image search platform

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist