转换字符串单词的第一个字母为大写
发表于:2007-06-30来源:作者:点击数:
标签:
Code Title: Proper Case Description: You know how to use UCase and LCase, now here‘’s Pcase! Ucase converts a string to all UPPERCASE, and of course Lcase does the opposite, but this will convert any text string to Proper Case. It basical
Code Title: Proper Case
Description: You know how to use UCase and LCase, now here‘’s Pcase! Ucase converts a string to all
UPPERCASE, and of course Lcase does the opposite, but this will convert any text string to Proper Case. It
basically capitalizes the first letter of every word in the string. Pretty cool, huh?!
Copy and paste this snippet as-is into your editor:
<%
Function PCase(strInput)
iPosition = 1
Do While InStr(iPosition, strInput, " ", 1) <> 0
iSpace = InStr(iPosition, strInput, " ", 1)
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
iPosition = iSpace + 1
Loop
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))
PCase = strOutput
End Function
%>
<html><body>
Then, in your asp, use the function like this:<br>
i.e.: <%=PCase(rs("PG"))%> or..<br>
i.e.: <%=PCase(myVariable)%> etc etc etc..<br>
</body></html>
原文转自:http://www.ltesting.net