The PCase function returns a string in proper case. If the input string is Null,
PCase returns Null. It's operation is similar to the built in LCase and UCase
VBScript functions. The PCase function capitalizes the first letter of each word
in the string and the remaining letters to lower case. vbTab's are stripped from
the string before processing. PCase may have unexpected results in strings
containing HTML mixed with text.
string = PCase(string)
Make a string proper case.
ASP Source Code:
a = "My dog has fleas and i wish they would go away." & _
vbCrLf & vbCrLf & "What can I do?" & vbCrLf & "help me out."
a = PCase(a)
In this example, a is equal to:
My Dog Has Fleas And I Wish They Would Go Away.
What Can I Do?
Help Me Out.
Private Function PCase(byVal string)
Dim Tmp, Word, Tmp1, Tmp2, firstCt, a, sentence, c, i
If IsNull(string) Then
PCase = Null
string = CStr( string )
a = Split( string, vbCrLf )
c = UBound(a)
i = 0
For each sentence in a
Tmp = Trim( sentence )
Tmp = split( sentence, " " )
For Each Word In Tmp
Word = Trim( Word )
Tmp1 = UCase( Left( Word, 1 ) )
Tmp2 = LCase( Mid( Word, 2 ) )
PCase = PCase & Tmp1 & tmp2 & " "
PCase = Left( PCase, Len(PCase) - 1 )
If i = c then
PCase = PCase & vbCrLf
i = i + 1