asp截取字符串的两种应用

2018-09-06 12:18

阅读:449

  1、纯粹的截取字符串
复制代码 代码如下:
functioncutstr(thestr1,strlen)
diml,t,c
l=len(thestr1)
ifl<1thenexitfunction
t=0
fordxy1=1tol
c=Abs(asc(Mid(thestr1,dxy1,1)))
ifc>255then
t=t+2
else
t=t+1
endif
ift>=strlenthen
thev=mid(thestr1,1,dxy1)
exitfor
else
thev=thestr1
endif
next
cutstr=thev
endfunction

2、截取字符串,不足用空格补上
复制代码 代码如下:
functioncutstr(thestr,strlen)
diml,t,c
l=len(thestr)
t=0
fordxy=1tol
c=Abs(asc(Mid(thestr,dxy,1)))
ifc>255then
t=t+2
else
t=t+1
endif
ift>=strlenthen
thev=left(thestr,dxy)
exitfor
else
bu=strlen-t
forbui=1tobu
strbu=
strbuall=strbuall&strbu
next
thev=thestr&strbuall
strbu=
strbuall=
endif
next
cutstr=thev
endfunction


评论


亲,登录后才可以留言!