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

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<br/>mydev.net >> Mydev.Net<br/>ANmar-space >> Anmar-Space

Views 692 Downloads 315

'text', 'convert', 'change', 'replace', 'substitute', 'modify', 'case', 'lower', 'upper', 'lcase', 'pcase', 'proper', 'pcase'

ANmarAmdeen
333
Texts + Strings Classic ASP
Revisions

v1.0