' ---------------------------------------------
' 返回字符串的长度:字节数
' ---------------------------------------------
function StringLen( str )
dim nLength, nLoop
nLength=0
StringLen = 0
nLength=len(str)
for nLoop = 1 to nLength
if asc(mid(str,nLoop,1))<0 then
StringLen=int(StringLen) + 2
else
StringLen=int(StringLen) + 1
end if
next
end function
可解决字符串中含有汉字时的长度计算问题
本文介绍了一种计算包含汉字的字符串长度的方法,通过遍历字符串并判断每个字符的ASCII值来确定其是汉字还是英文字符,进而计算出准确的长度。
207

被折叠的 条评论
为什么被折叠?



