ChgStringTitleCase




Dim strString as String
strString = "joe bloggs"
strString = TitleCaps strString
strString will now equal "Joe Bloggs"
Title Caps Functions
Function TitleCaps(InString As String) As String
Dim OutString As String, CurrentLetter As String
Dim CurrentWord As String, TCaps As String
Dim StrCount As Integer, I As Byte
OutString = ""
If InString = "" Then
TitleCaps = ""
Exit Function
End If
CurrentWord = ""
For StrCount = 1 To Len(InString)
CurrentLetter = Mid(InString, StrCount, 1)
CurrentWord = CurrentWord + CurrentLetter
If InStr(" .,/\;:-!?[]()#", CurrentLetter) <> 0 Or _
StrCount = Len(InString) Then
TCaps = UCase(Left(CurrentWord, 1))
For I = 2 To Len(CurrentWord)
TCaps = TCaps & Mid(CurrentWord, I, 1)
Next
OutString = OutString & TCaps
CurrentWord = ""
End If
Next
TitleCaps = OutString
End Function

Useful for certain type of applications es. for names and
addresses etc, being able to Title Caps (ie capitalise first
letter of each word) is achieved with the following function.
This code also allows you to pass names like "mcDonald", and
have the correct name "McDonald" returned.










( chgstringtitlecase.html )- by Paolo Puglisi - Modifica del 17/12/2023