# Capitalization code - 50 pts

Does anyone have code that will capitalize the first letter of each word in a string?  Thanks!
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
It ought to look something like this

Function Capitalize(ByVal Value As String) As String

Dim a As Long
Dim LenValue As Long

LenValue = Len(Value)

Mid\$(Value, 1, 1) = UCase\$(Mid\$(Value, 1, 1))
For a = 1 To LenValue
Select Case Mid\$(Value, a, 1)
Case " "
If (a < LenValue) Then
Mid\$(Value, a + 1, 1) = UCase\$(Mid\$(Value, a + 1, 1))
End If
End Select
Next
Capitalize = Value

End Function

You can add more characters at the end of the Case line if you'd like, this function will upper-case the character after every space + the very first character in the string.
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Awesome, Thanks a lot!
0
Commented:
neymeyer,

Here's another suggestion:

Function PCase(x As String) As String
Dim p As Long
PCase = Trim(LCase(x))
Do
Mid(PCase, p + 1, 1) = UCase(Mid(PCase, p + 1, 1))
p = InStr(p + 1, PCase, " ")
Loop Until p = 0
End Function

Ture Magnusson