PCase

Converts a string into proper case
PCase or ProperCase since Classic ASP does not have that functionality
Capitalize 1st letter of words preceded by a space, a dot, a dash, an underscore, single quote or a number
Capitalize 1st letter of words preceded by carriage return plus linefeed combination

CodeFunctionName
What is this?

Public

Tested

Original Work
Function ProperCase(Str)
ProperCase = PCase(Str)
End Function
Function PCase(str)
' This function capitalizes each of the words in a sentence.
Dim t
t = str
If t < > "" Then
t = UCase(Mid(t, 1, 1)) & Right(t, Len(t) - 1)
For i = 1 To Len(t) - 1
If Mid(t, i, 2) = Chr(13) + Chr(10) Then
' Capitalize words preceded by carriage return plus linefeed combination.
t = Mid(t, 1, i) & UCase(Mid(t, i + 2, 1)) & Mid(t, i+3, Len(t))
End If
If Mid(t, i, 1) = " " or Mid(t, i, 1) = "." or Mid(t, i, 1) = "_" or Mid(t, i, 1) = "-" or Mid(t, i, 1) = "'" or isnumeric(Mid(t, i, 1)) Then
' Capitalize words preceded by a space, a dot, a dash, an underscore, or a number
t = Mid(t, 1, i) & UCase(Mid(t, i + 1, 1)) & Mid(t, i+2, Len(t))
End If
Next
End If
PCase = t
End Function

Str

mywebsite >> Mywebsite
mydev.net >> Mydev.Net
ANmar-space >> Anmar-Space

Views 4,485

Downloads 1,447

CodeID
DB ID