上一篇:ASP中令人震撼的Debug类(VBScript) >>
可以把文章标题中的英文单词的首字母变成大写的函数
可以把文章标题中的英文单词的首字母变成大写:)
效果演示:
<%
function PCase(strInput)
‘’Variable declaration.
Dim strArr
Dim tmpWord
Dim tmpString
Dim last
‘’Create an array To store Each word In the String separately.
strArr = split(strInput," ")
if ubound(strArr) > 0 Then
For x = lbound(strArr) To ubound(strArr)
‘’Set Each word To lower Case initially.
strArr(x) = LCase(strArr(x))
‘’Skip the unimportant words.
Select Case strArr(x)
Case "a"
Case "an"
Case "and"
Case "but"
Case "by"
Case "for"
Case "in"
Case "into"
Case "is"
Case "of"
Case "off"
Case "on"
Case "onto"
Case "or"
Case "the"
Case "to"
Case "a.m."
strArr(x) = "A.M."
Case "p.m."
strArr(x) = "P.M."
Case "b.c."
strArr(x) = "B.C."
Case "a.d."
strArr(x) = "A.D."
Case Else
‘’Capitalize the first letter, but don‘’t forget To take into account that
‘’the String may be in Single or Double quotes.
if len(strArr(x)) > 1 Then
if mid(strArr(x),1,1) = "‘’" or mid(strArr(x),1,1) = """" Then
tmpWord = mid(strArr(x),1,1) & Ucase(mid(strArr(x),2,1)) & mid(strArr(x),3,len(strArr(x))-2)
Else
tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
End if
strArr(x) = tmpWord
End if
End Select
‘’The unimportant words may need To be capitalized if they follow a dash, colon,
‘’semi-colon, Single quote or Double quote.
if x > 0 Then
if instr(strArr(x-1),"-") _
or instr(strArr(x-1),":") _
or instr(strArr(x-1),";") Then
tmpWord = Ucase(mid(strArr(x),1,1)) & mid(strArr(x),2,len(strArr(x))-1)
strArr(x) = tmpWord
End if
End if
Next
Else
strArr(0) = LCase(strArr(0))
End if
‘’Make sure the first word In the array is upper case, but don‘’t forget To take into account
‘’that the String may be in Single or Double quotes.
if mid(strArr(0),1,1) = "‘’" or mid(strArr(0),1,1) = """" Then
tmpWord = mid(strArr(0),1,1) & Ucase(mid(strArr(0),2,1)) & mid(strArr(0),3,len(strArr(0))-2)
Else
tmpWord = Ucase(mid(strArr(0),1,1)) & mid(strArr(0),2,len(strArr(0))-1)
End if
strArr(0) = tmpWord
‘’Also, make sure the last word In the array is upper case, but don‘’t forget To take into account
‘’that the String may be in Single or Double quotes.
last = ubound(strArr)
if mid(strArr(last),1,1) = "‘’" or mid(strArr(last),1,1) = """" Then
tmpWord = mid(strArr(last),1,1) & Ucase(mid(strArr(last),2,1)) & mid(strArr(0),3,len(strArr(last))-2)
Else
tmpWord = Ucase(mid(strArr(last),1,1)) & mid(strArr(last),2,len(strArr(last))-1)
End if
strArr(last) = tmpWord
‘’Rebuild the whole String from the array parts.
For x = lbound(strArr) To ubound(strArr)
tmpString = tmpString & strArr(x) & " "
Next
PCase = tmpString
End function
%>
下一篇:ASP中一个用VBScript写的随机数类 >>
相关文章:
- · ASP中一个页面多个表单的提交
- · ASP中存储过程调用的两种方式,以及不采用存储过程的方式比较
- · 关于ASP的(VBScript)类,只希望给初学者看一看,希望对你们有帮助
- · 认识ASP内置的对象
- · ASP内置组件
- · ASP内置对象
- · ASP函数
- · 随机生成不重复记录的伪函数
- · ASP中模板思想的应用
- · ASP设计常见问题及解答精要-2
- · ASP设计常见问题及解答精要-1
- · 为你的网页加一个Loading !!!!
- · ASP分页显示之乱盖
- · 用ASP、VB和XML建立互联网应用程序(3)
- · 用ASP、VB和XML建立互联网应用程序(2)
- · 用ASP、VB和XML建立互联网应用程序(1)
- · 图片上传前取得尺寸
- · ASP操作Excel技术总结
- · Microsoft Word 对象
- · 如何在不刷新页面的情况下调用远程ASP
- · 关于<SELECT>的无限级联(省|市|县|乡|村|...)
- · ASP如何获取真实IP地址
- · 改进ASP应用程序中的字符串处理性能
- · ASP编程中15个非常有用的例子
- · ASP导出Excel数据的四种方法
- · 让你的ASP运行于非Windows平台
- · 测试访问者电脑的分辨率
- · 全面优化ASP应用程序的性能(转载)
- · Asp正则表达式在UBB论坛中的应用
- · 如何获得真实的ip
- · 面向对象的ASP技术:思考与实践
- · 文件上传之后
- · asp分页显示详论
- · 用asp打开光驱!
- · ASP计数器设计详解(转载)
- · 在ASP中使用SQL语句之2:用WHERE子句设置查询条件
- · 在ASP中使用SQL语句之1:SELECT 语句
- · ASP的运行环境和虚拟目录的设置
