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

ASP
ASP技巧研究:ASP Error对象的相关知识
ASP模拟MVC模型的编程方式
学ASP应该注意ASP程序书写的规范
用文本+ASP打造新闻发布系统
ASP Session对象的集合以及属性方法事件
ASP防止盗链或防止下载的方法
ASP开发中存储过程应用详解
ASP脚本语言的19个基本技巧使用
ASP中使用Form和QueryString集合
在ASP中访问和更新Cookies集合
在ASP中操作HTTP报头方法分析
建立三层结构的ASP应用程序
ASP动态网页编程的19个基本技巧
ASP教程:制作登陆验证页面程序
asp正则表达式详细说明
使用ASP订制自己的XML文件读写方法
ASP中的Debug类--VBScript
Asp中如何设计跨越域的Cookie
DHTML+XML+ASP+CSS的树形目录
实例一则 ASP程序中输出Excel文件

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


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