文章·资料 电脑软件 手机软件 网站源码




    本 站 搜 索
   推 荐 文 章        More...
华硕易电脑(ASUS Eee PC 10..
先来段开场白:为了外出携带方便..
Acronis True Image 使用..
  一款可以在Windows下使用..
Norton Ghost 使用详解
一、分区备份   使用Ghost..
    文 章 阅 读 排 行
关于 Firefox 在中国持续..
亲爱的 Firefox 用户及 Firefox..
解决 Windows XP 文件夹共..
  公司里的一台打印机设置了..
Windows 系统安装或备份时 ..
【ISO 文件】 ISO 文件其实..
华硕易电脑(ASUS Eee PC 10..
先来段开场白:为了外出携带方便..
使用脚本(JavaScript)实现..
Script Language=JavaScript!--..
为啥现在的电脑都不能安装 ..
说实话,这几年如果你尝试在..
PakePlus 构建 APP 需要 Gi..
PakePlus 是一个基于 Rust Taur..
ASP:Persits ASPMail 发送..
【发送邮件测试代码下载】..
VMware Workstation:安装..
编写这份虚拟机安装的图文教程..
Microsoft Windows 系统下..
网站名称:I Tell You,我告诉你 ..
 文 章 信 息
ASP字符串截取函数
评论()〗〖留言〗〖收藏
〖文章分类:电脑·手机·网络 / 网站设计·开发·优化〗〖阅读选项
ASP 字符串截取函数
’*********************************************************
’函数:cutStr[str(strlen)]
’参数:str,待处理的字符串,strlen,截取的长度
’作者:木木
’日期:2007/7/12
’描述:截取指定长度的字符串
’示例:<%=cutStr("欢迎光临阿里西西",5)%>
’*********************************************************
function cutStr(str,strlen)
If str = "" Then
cutStr = "cutStr函数异常:字符串为空"
exit function
End If
’------------来源长度检查
If strlen = "" Then
cutStr = "cutStr函数异常:长度未指定"
exit function
End If
If CInt(strlen) = 0 Then
cutStr = "cutStr函数异常:长度为0"
exit function
End If
’----------检测来源字符长度
dim l,t,c,i
l=len(str)
t=0
’----------循环截取字符
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
’------判断是否汉字
if c>255 then
t=t+2
else
t=t+1
end If
’------判断是否到达指定长度
if t>=strlen then
cutStr=left(str,i)&".."
exit for
else
cutStr=str
end if
next
cutStr=replace(cutStr,chr(10),"")
end function
’’*********************************************************
’函数:strlen[str]
’参数:str,待处理的字符串
’作者:木木
’日期:2007/7/12
’描述:判断字符串长度,汉字长度为2
’示例:<%=strlen("欢迎光临阿里西西")%>
’*********************************************************
Function strlen(str)
dim p_len
p_len=0
strlen=0
if trim(str)<>"" then
p_len=len(trim(str))
for xx=1 to p_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
End Function
截取左边的n个字符’*********************************************************
’函数:LeftTrue(str,n)
’参数:str,待处理的字符串,n,截取的长度
’作者:木木
’日期:2007/7/12
’描述:显示左边的n个字符(自动识别汉字)函数
’示例:<%=LeftTrue("欢迎光临阿里西西",6)%>
’*********************************************************
Function LeftTrue(str,n)
If len(str)<=n/2 Then
LeftTrue=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
t=l
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
If t>n Then exit for
TStr=TStr&(mid(str,i,1))
next
LeftTrue = TStr
End If
End Function

文章作者:未知  更新日期:2009-07-07
〖文章浏览:〗〖发送文章〗〖打印文章
〖文章阅读说明〗
·本站大部分文章转载于网络,如有侵权请留言告知,本站即做删除处理。
·本站法律法规类文章转载自[中国政府网(www.org.cn)],相关法律法规如有修订,请浏览[中国政府网]网站。
·本站转载的文章,不为其有效性,实效性,安全性,可用性等做保证。
·如果有什么问题,或者意见建议,请联系[网站管理员]。