日期:2012-05-27  浏览次数:20438 次

这是2个对字符串处理的互逆函数
功能:移动字符串
用发:arymoveleft("字符串",移动的个数)
例:
dim strg
strg="123456789"
strg=arymoveleft(strg,2)

结果:strg="345678912"



Public Function arymoveleft(str, count)
If count = 0 Then
arymoveleft = str
Exit Function
End If
Dim a()
strlen = Len(str)
ReDim a(strlen)
For i = 1 To Len(str)
a(i) = Mid(str, i, 1)
Next
temp = a(1)
For i = 2 To Len(str)
a(i - 1) = a(i)
Next
a(strlen) = temp
For i = 1 To Len(str)
result = result & a(i)
Next
arymoveleft = arymoveleft(result, count - 1)
End Function
Public Function arymoveright(str, count)
If count = 0 Then
arymoveright = str
Exit Function
End If
Dim a()
strlen = Len(str)
ReDim a(strlen)
For i = 1 To Len(str)
a(i) = Mid(str, i, 1)
Next
temp = a(strlen)
For i = Len(str) To 2 Step -1
a(i) = a(i - 1)
Next
a(1) = temp
For i = 1 To Len(str)
result = result & a(i)
Next
arymoveright = arymoveright(result, count - 1)
End Function