<pre id=\\\"best-answer-content\\\">function sc_left(str,strlen) ‘str是你要截取的文章,strlen是你要的长度,比如30
if str=\\\"\\\" then
sc_left=\\\"\\\"
exit function
’如果为空退出
end if
dim l,t,c, i
l=len(str)
t=0
for i=1 to l ‘从第一个字符开始循环到你文章结。
c=Abs(Asc(Mid(str,i,1))) ’这是返回ascII码,大于255的就计算为2
if c255 then
‘这是非字母数字,加2
t=t 2
else
t=t 1
‘字母数字
end if
if t=strlen*2 then
’30*2=60,因为你要30个字,我理解为汉字,那么字母就数字就要加倍。
sc_left=left(str,i) \\\",\\\" \\\")
|