ProperCase Function :
Returns a string in proper case.
Description:
The ProperCase function returns a string in proper case. If the input string is Null, ProperCase returns Null. It's operation is similar to the built in LCase and UCase VBScript functions.
The ProperCase 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. ProperCase may have unexpected results in strings containing HTML mixed with text.
Syntax:
string = ProperCase(string)
Details:
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.
Example:
<%
'--- Make a string in proper case. Dim a a = "My dog has fleas and i wish they would go away." & _ vbCrLf & vbCrLf & "What can I do?" & vbCrLf & "help me out." Response.Write ProperCase(a) '--- Returns: My Dog Has Fleas And I Wish They Would Go Away. What Can I Do? Help Me Out
%>
ASP Source Code:
<%
Private Function ProperCase(byVal string) Dim Tmp, Word, Tmp1, Tmp2, firstCt, a, sentence, c, i If IsNull(string) Then PCase = Null Exit Function Else string = CStr( string ) End If 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 ) ) ProperCase = ProperCase & Tmp1 & tmp2 & " " Next ProperCase = Left( ProperCase, Len(ProperCase) - 1 ) If i = c then Else ProperCase = ProperCase & vbCrLf End If i = i + 1 Next End Function '--- ProperCase
%>
|