Posted By

Shurik76 on 10/29/09


Tagged

case proper PCase


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

benrudolph
dan74


Proper Case String Conversion


 / Published in: ASP
 

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

  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

Report this snippet  

You need to login to post a comment.