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

ASP
ASP实例:是否支持XmlHttp组件的判断
ASP对XML文档中文本的增加、删除、修改、查看
ASP操作XML文件的主要方法和实现
asp控制xml数据库的6段代码
ASP操作XML的类
ASP关于类的Let,Set和Get的用法的异同
ASP错误解决:800a003a错误
XMLHTTP Post Form时的表单乱码
IIS7.0在Vista系统下安装注意事项
asp文件打不开的原因
asp根据表单自动生成sql语句的函数
彻底解决XP下IIS无法解释ASP和PHP的问题
ASP教程:0177:800401f3错误解决
Service Unavailable错误的解决
ASP留言本教程
ASP教程:6大对象和数据库操作简单学
配置IIS蜜罐与黑客攻击
WEB共享与IIS相结合快速建立本地网站
IIS6架设网站的问题总结
HTTP 500 - 内部服务器错误的解决

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


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