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

ASP
[原创]本人常用的asp代码
asp防止刷新功能
生成所有页面的效果+分页生成
ASP在SQL Server 2000中新建帐号和权限
PR值查询代码制作
GetRows的用法详解!
ASP简洁的多重查询的解决方案
ASP实现SQL备份、恢复
用ASP写组件
ASP中Request对象获取客户端数据的顺序(容易忽略)
利用Adodb.Stream制作彩色验证码
ASP 类 Class入门 推荐
asp数据库防下载处理
浏览文件夹下面所有图片
结合asp和存储过程做的搜索程序
实现支持逻辑搜索/单词搜索/词组搜索+支持OR/AND关键字的VBS CLASS!
支持加号空格的查询
取得表单提交的所有数据
发邮件的asp(CDONTS.NewMail)
使用FSO把文本信息导入数据库

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 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