asp截取字符串的兩種應(yīng)用 原創(chuàng)
原創(chuàng) 更新時間:2006年08月30日 00:00:00 原創(chuàng) 作者:
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、截取字符串,不足用空格補(bǔ)上
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
復(fù)制代碼 代碼如下:
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、截取字符串,不足用空格補(bǔ)上
復(fù)制代碼 代碼如下:
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
相關(guān)文章
SQL查詢語句通配符與ACCESS模糊查詢like的解決方法
我今天在寫個頁面的時候,也很郁悶,表中明明有記錄,但在ASP里就是搜索不到,原來是因?yàn)閍ccess與SQL的查詢語句通配符問題不同所引起的。2011-02-02asp有效防止網(wǎng)站留言板出現(xiàn)垃圾留言/評論實(shí)現(xiàn)思路
如何有效防止網(wǎng)站(留言板)出現(xiàn)垃圾留言,垃圾評論?本文提供詳細(xì)解決思路與實(shí)現(xiàn)步驟,需要了解的朋友可以參考下2012-12-12asp中獲取當(dāng)前月份距離以前某個時間的月份數(shù)
獲取當(dāng)前月份距離以前某個時間的月份數(shù),asp都是用DateDiff函數(shù)來實(shí)現(xiàn)2012-04-04asp實(shí)現(xiàn)的sha1加密解密代碼(和C#兼容)
這篇文章主要介紹了asp實(shí)現(xiàn)的sha1加密解密代碼,可以和ASP.NET(C#)相互兼容,需要的朋友可以參考下2014-08-08