谁帮我检查一下这个方法哪里错了???
下面这个方法是我自己写的.主要功能是分割Byte型数组,然后保存为String型数组.
可是在实验时出现了.下标越界的错误.望高手指教.
参数ByteSZ 要查找的数组
参数FindStr 要查找的字符
参数OutPutStr 输出的字符数组
Public Function Bplit(ByRef ByteSZ() As Byte, ByVal FindStr As String, ByRef OutPutStr() As String) As Long Dim l As Long Dim u As Long Dim fu As Long Dim oldwz As Long Dim wz As Long Dim Start As Long Dim lngIsFind As Long Dim FS() As Byte Dim x As Long '------------------------------初始化变量 On Error Resume Next x = 0 Start = 0 InStr_Array = -1 wz = 0 oldwz = 0 l = LBound(ByteSZ) u = UBound(ByteSZ) If u = 0 Then Exit Function FS = StrConv(FindStr, vbFromUnicode) fu = UBound(FS) '------------------------------变量初始化结束 GoTo czcz: For i = Start To u '被查找的数组上标 lngIsFind = 1 '变量 For j = 0 To fu '要查找的字符上标 If ByteSZ(i + j) < &HA0 And FS(j) < &HA0 Then If UCase(Chr(ByteSZ(i + j))) <> UCase(Chr(FS(j))) Then lngIsFind = 0 Bplit = 1 Exit For End If Bplit = 3 Else If ByteSZ(i + j) <> FS(j) Then lngIsFind = 0 Bplit = 1 Exit For End If Bplit = 4 End If Next j If lngIsFind = 1 Then wz = i Bplit = 5 Exit For End If Next i For m = Start To wz OutPutStr(x) = OutPutStr(x) & Chr(ByteSZ(m)) Next m x = x + 1 Start = wz + fu + 1 If x = 1 Then oldwz = wz Else If wz = oldwz Then '如果这次的出现位置与上次的一样,就退出本函数 Exit Function Else '否则把当前位置赋给老地址,并继续循环 oldwz = wz GoTo cz End If End IfEnd Function