# 求一个字符串函数

tmpx 2006-01-09 10:34:29

...全文
46 点赞 收藏 3

3 条回复

boyd1985 2006-01-09

KimSoft 2006-01-09

KimSoft 2006-01-09
'------------------------------------------------------------
'　作用：让Len,Left,Right函数识别中文
' 对中文识别为两个字符，ASCII码为一个
' 可用此函数代替Len,Left,Right函数
'------------------------------------------------------------

Function StrLen(Str)
strTemp = Len(Str)
For I = 1 To strTemp
strTest = (Mid(Str, I, 1))
If Asc(strTest) > 0 Then
StrLen = StrLen + 1
Else
StrLen = StrLen + 2
End If
Next
End Function

Function StrLeft(Str, L)
strTemp = Len(Str)
For I = 1 To strTemp
strTest = (Mid(Str, I, 1))
StrLeft = StrLeft & strTest
If Asc(strTest) > 0 Then
Lens = Lens + 1
Else
Lens = Lens + 2
End If
If Lens >= L Then Exit For
Next
End Function

Function StrRight(Str, L)
strTemp = Len(Str)
For I = strTemp To 1 Step -1
strTest = (Mid(Str, I, 1))
StrRight = strTest & StrRight
If Asc(strTest) > 0 Then
Lens = Lens + 1
Else
Lens = Lens + 2
End If
If Lens >= L Then Exit For
Next
End Function

ASP

2.8w+

ASP即Active Server Pages，是Microsoft公司开发的服务器端脚本环境。

2006-01-09 10:34