欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

asp截取字符串的两种应用 原创

程序员文章站 2022-06-15 14:21:31
1、纯粹的截取字符串复制代码 代码如下:function cutstr(thestr1,strlen) dim l,t,c l=len(thestr1)...
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