Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Title Case in VB 1

Status
Not open for further replies.

Faheem786

Programmer
Sep 5, 2001
30
HK
Friends

Is there any function in vb which is used to Title Case a word? eg: "my name" or "MY NAME" should be displayed as "My Name".

I only know about lcase and ucase.

Pls help me in this.

Thanks in advance.

Faheem
 
I had to write my own:
Code:
Public Function TitleCase(sVal As String) As String
    Dim i As Long, sChar As String, bFlag As Boolean
    bFlag = False
    TitleCase = ""
    For i = 1 To Len(sVal)
        sChar = Left(sVal, 1)
        sVal = Right(sVal, Len(sVal) - 1)
        If i = 1 Or bFlag = True Then
            TitleCase = TitleCase & UCase(sChar)
            bFlag = False
        Else
            TitleCase = TitleCase & LCase(sChar)
        End If
        If sChar = " " Then bFlag = True
    Next i
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top