主题:  关于len这个函数的不解??

ccbwx

职务:普通成员
等级:1
金币:0.0
发贴:78
#12003/2/2 0:41:43
<%
dim aa,bb,cc
aa="abcdefghijklmn"
bb="中华人民abcdef"
cc="中华人民共和国"
response.write aa&" "&len(aa)&"
"
response.write bb&" "&len(bb)&"
"
response.write cc&" "&len(cc)&"
"
%>
执行后结果如下:
abcdefghijklmn 14
中华人民abcdef 10
中华人民共和国 7
请问如何得到汉字的具体长度,如何写代码才能得到:
abcdefghijklmn 14
中华人民abcdef 14
中华人民共和国 14
谁能帮我???谢谢!!!!



叮咚虫

职务:普通成员
等级:1
金币:0.0
发贴:89
#22003/2/2 2:46:58
Function Strlength(Str)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
If Asc(Test_Str)>0 Then
Strlength=Strlength+1
Else
Strlength=Strlength+2
End If
Next
End Function
Function Strleft(Str,L)
Temp_Str=Len(Str)
For I=1 To Temp_Str
Test_Str=(Mid(Str,I,1))
Strleft=Strleft&Test_Str
If Asc(Test_Str)>0 Then
lens=lens+1
Else
lens=lens+2
End If
If lens>=L Then Exit For
Next
End Function
Function Strright(Str,L)
Temp_Str=Len(Str)
For i = Temp_Str to 1 step -1
Test_Str=(Mid(Str,I,1))
Strright=Test_Str&Strright
If Asc(Test_Str)>0 Then
lens=lens+1
Else
lens=lens+2
End If
If lens>=L Then Exit For
Next
End Function



ccbwx

职务:普通成员
等级:1
金币:0.0
发贴:78
#32003/2/3 3:43:07
谢谢!叮咚虫,我回去试试!
还有个问题为什么你的回复我没有收到邮件通知?我在发贴子的时候
已经选上了回复通知呀!!!