Search This Blog

UCase on the first letter 'Together they created TCase code for ASP

stringText = "this IS a TeStT OF sTuff !"
response.write "<B>This is the original string:</b> '" & stringText & "'<BR><BR><BR>"
' TCase code
Function TCase(stringText)
 stringText = Trim(stringText)
 stringTextLCASE = lcase(stringText)
 stringTextSplit = split(stringTextLCASE, " ")
 stringTextoutput = ""
 for each i in stringTextSplit
  'stringTextoutput = stringTextoutput & replace(i, left(i,1), Ucase(left(i,1))) & " "
  titlecaseletter = ucase(left(i,1))
  xcount = len(i) - 1
  titleword = right(i,xcount)
  stringTextoutput = stringTextoutput & " " & titlecaseletter & titleword
 Next
 TCase = stringTextoutput
end function
'text output
response.write TCase(stringText)