转换字符串单词的第一个字母为大写

时间:2007-10-18 10:50:00 

本文介绍了一种将英文字符首个字母串转换为大写的asp代码,当然这个功能可能英文网站比较有用。

转换大写功能英文介绍:
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:

实现转换大写的asp函数代码:


<% 
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> 
转换字符串单词的第一个字母大写使用方法:<br> 
读取数据库字段例子: <%=PCase(rs("PG"))%> <br> 
读取asp参数.: <%=PCase(myVariable)%> <br> 
直接写入字符串.: <%=PCase("asp之家 www.aspxhome.com")%> <br> 
</body></html> 


标签:大写,字符串
0
投稿

猜你喜欢

  • 一次MySQL性能优化实战

    2009-03-09 15:01:00
  • 网站中美好的细节

    2011-07-13 18:43:07
  • 倾斜的鼠标翻转导航制作上的烦恼

    2007-06-20 16:39:00
  • ASP所有的Session变量获取实现代码

    2011-03-11 10:44:00
  • 优化你的ASP程序及优化网页

    2007-10-06 23:02:00
  • 用Frontpage设计网站主页

    2008-10-23 13:44:00
  • asp当中判断函数一览

    2010-05-27 12:15:00
  • 用JavaScript判断字符串长度

    2009-10-29 12:15:00
  • 两个百度WEB面试题 怎么做?

    2010-09-03 18:40:00
  • 在 CSS 中关于字体处理效果的思考

    2008-04-25 22:57:00
  • 不建议使用jquery的情况

    2008-03-10 12:28:00
  • 解析SQL Server与ASP互操作的时间处理

    2009-02-01 16:40:00
  • CSS改变字体而不影响网页

    2010-10-20 20:11:00
  • 浅论网站用户粘性的提高和增强

    2008-05-15 07:14:00
  • 從無到有實現一個xml數據庫登錄驗証

    2008-09-05 17:12:00
  • 品牌的统一体验

    2010-05-19 13:08:00
  • ubuntu下简单配置mysql数据库

    2009-07-31 09:17:00
  • 简单解读面包屑

    2009-06-09 14:16:00
  • 3个比较好用的asp检查函数

    2007-09-24 13:25:00
  • 如何实现固定长度的自动编号?

    2010-06-03 10:08:00
  • asp之家 网络编程 m.aspxhome.com