当前位置: 首页 > 图文教程 > 网络编程 > ASP > [原创]asp截取字符串的两种应用

ASP
[原创]asp截取字符串的两种应用
内容分页函数
一搜图片搜索小偷
Web代理(Asp版)
实例分析ASP上传漏洞入侵实战及扩展
asp如何用discuz会员系统
asp javascript在线管理
newasp中main类
文章列表类别
[ASP]精华代码
登陆asp class
信息采集程序
用XML+FSO+JS实现服务器端文件的
vithink小文件自动实现文件浏览下载
使用FSO按文件大小浏览文件目录并进行删除操作
列出指定目录下的所有文件和目录
日期函数扩展类Ver0.1.1
管理员登录
cls_main.asp
asp提高首页性能的一个技巧

ASP 中的 [原创]asp截取字符串的两种应用


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 30 ::
收藏到网摘: n/a

1、纯粹的截取字符串
复制代码 代码如下:

function cutstr(thestr1,strlen)
dim l,t,c
l=len(thestr1)
if l<1 then exit function
t=0
for dxy1=1 to l
c=Abs(asc(Mid(thestr1,dxy1,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
thev=mid(thestr1,1,dxy1)
exit for
else
thev=thestr1
end if
next
cutstr=thev
end function

2、截取字符串,不足用空格补上
复制代码 代码如下:

function cutstr(thestr,strlen)
dim l,t,c
l=len(thestr)
t=0
for dxy=1 to l
c=Abs(asc(Mid(thestr,dxy,1)))
if c>255 then
t=t+2
else
t=t+1
end if
if t>=strlen then
thev=left(thestr,dxy)
exit for
else
bu=strlen-t
for bui=1 to bu
strbu=" "
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=""
strbuall=""
end if
next
cutstr=thev
end function