Function LeadingCapitals(str As String) As String
Try
Dim tmpSTR As String = str
Mid(tmpSTR, 1, 1) = UCase(Mid(tmpSTR, 1, 1))
For i As Integer = 2 To Len(tmpSTR)
If Mid(tmpSTR, i - 1, 1) = " " Then
Mid(tmpSTR, i, 1) = UCase(Mid(tmpSTR, i, 1))
Else
Mid(tmpSTR, i, 1) = LCase(Mid(tmpSTR, i, 1))
End If
Next
LeadingCapitals = tmpSTR
Catch ex As Exception
LeadingCapitals = str
End Try
End Function
Validation scripting guide
Back to scripting overview