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

ASP
ASP六大对象介绍
使用Filter实现信息的二次检索
让弹出窗口变得“听话”一些
在ASP中利用“正则表达式” 对象实现UBB风格的论坛
“Web 匿名用户”帐户密码的位置
对一些编程初学者的良言警句
ASP编程中15个非常有用的例子
精彩:ASP遗留的二十大积习
关于Asp代码与页面的分离
教大家如何利用ASP打造网站论坛DIY(1)
教大家如何利用ASP打造网站论坛DIY(2)
网站安全:防范ASP木马的十大基本原则
用ASP设计一个留言薄
趣味访客计数器设计两则
我的ASP之旅—二级联动菜单制作
ASP编程--新手上路篇:ASP技术简介
用ASP实现网上考试系统
请注意!常见的ASP脚本攻击及防范技巧
ASP开发的WAP格式简易邮件系统实例
asp基础教程:网页间数据传递方法小结

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 44 ::
收藏到网摘: 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