首页 | 生活百科 | 电脑网络 | 高手学堂 | 语录名言 | 读书文学 | 极品软件 | 奇趣图片 | 站长微博
 您的位置： 精品百字节网 >> 电脑网络 >> 网络编程 >> 编程问题 >> 正文 当前没有通告！
□  首字母大写函数 ［ 作者：作者不详     来源：互连网     点击数：     更新时间：2007-10-18     文章录入：Admin
【字体：
 [内容提要]暂无简介
'//首字母变成大写的函数
Function PCase(strInput)
'Variable declaration.
Dim strArr
Dim tmpWord
Dim tmpString
Dim last
Dim x
'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实现QQ在线查询功能

最新图文 ◇  网友评论：（只显示最新5条。评论内容只代表网友观点，与本站立场无关！）
 关于本站 | 免责申明 | 网站地图 | 联系站长 | 友情链接 | 与我同在
 冀ICP备06032589号【虚拟化精英群 】   Copyright© 2006-2009 100byte.Com All Rights Reserved 网站声明:本网站是公益性质网站,部分内容来源于网络,如有侵犯您权利的地方,请与精品百字节站长联系,尽快修正. Powered By CreateLive CMS 本站法律顾问:(冀港)武镇海律师  