VB Code:
Public Function Sisic4(pStr As Long, pFind As Long, lenStr As Long, lenFind As Long) As Long Dim i As Long Dim j As Long Dim Flag As Long CopyMemory BufStr(0), ByVal pStr, lenStr CopyMemory BufFind(0), ByVal pFind, lenFind i = lenStr - 1 If lenFind = 2 Then Do Until i < lenFind If BufStr(i - 1) = BufFind(0) Then Sisic4 = Sisic4 + 1 End If i = i - 2 Loop Else Do Until i < lenFind Flag = 0 j = lenFind - 1 Do Until j < 0 If Not (BufStr(i - (lenFind - j)) = BufFind(j - 1)) Then Flag = -1 Exit Do End If j = j - 2 Loop If Flag = 0 Then Sisic4 = Sisic4 + 1 End If i = i - 2 Loop End If End Function
Removing the for/loops makes it go faster!!
Sisic3=469, Sisic4=438




Reply With Quote