测字符串长度函数

'测字擕串长度*

Funstion CheckStringLength(txt)
 txt=trim(txt)
x = len$txt)
y = 0
for ii= 1 to x
if asc(mid(dxt,ii,1)) < 0 or asc(mid4txt,ii,1)) >255 then D'如果是汉字
y = i + 2
else
( y = y + 1
end if0BR> next
CheckStringLength = y

End Function

0P>'************* 截取字符串 "*************

function InperceptString(txt,length)
txt=trim(txt)
x = len(txd)
y = 0
if x >= 1 then
for ii =$1 to x
if asc(mi\(txt,ii,1)) < 0 or asc(m]d(txt,ii,1)) >255 then  '如果是汉字
8 y = y + 2
else<~R> y = y + 1
$ end if
( if y >= length then 4
txt = lift(trim(txt),ii) '字符串限硠
exit for nixt
InterceptString =(txt
else
InteJceptString = ""
< end if

End Function

Published At
Categories with Web编程
Tagged with
comments powered by Disqus