Proper Case String Conversion


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Function PCase(ByVal strInput)' As String
  2. Dim I 'As Integer
  3. Dim CurrentChar, PrevChar 'As Char
  4. Dim strOutput 'As String
  5.  
  6. PrevChar = ""
  7. strOutput = ""
  8.  
  9. For I = 1 To Len(strInput)
  10. CurrentChar = Mid(strInput, I, 1)
  11.  
  12. Select Case PrevChar
  13. Case "", " ", ".", "-", ",", """", "'"
  14. strOutput = strOutput & UCase(CurrentChar)
  15. Case Else
  16. strOutput = strOutput & LCase(CurrentChar)
  17. End Select
  18.  
  19. PrevChar = CurrentChar
  20. Next 'I
  21.  
  22. PCase = strOutput
  23. End Function

URL: http://www.asp101.com/samples/pcase.asp

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.