首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > 代码乐园 >
    7i24 .Com  
  转换字符串单词的第一个字母为大写

7i24.Com不停为您服务
转换字符串单词的第一个字母为大写

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:

i.e.: <%=PCase(rs("PG"))%> or..

i.e.: <%=PCase(myVariable)%> etc etc etc..

</body></html>





  2002年1月9日  阅读 769 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: 计算文件下载时间
下一篇: 遍历目录以及目录下文件的函数
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利