Quizá ya un poco tarde...
Aqui dejo mi 2ª forma, a diferencia de todas las demas sin depender de Mid(), Split()...
Recordar quitar comprobación en los límites de arrays al compilar!
Debería haber tambien tests con cadenas laaaargas!
DoEvents!
Aqui dejo mi 2ª forma, a diferencia de todas las demas sin depender de Mid(), Split()...
Código (vb) [Seleccionar]
Option Explicit
Option Base 0
Private Declare Function ArrayPtr Lib "msvbvm60" Alias "VarPtr" (ByRef Ptr() As Any) As Long
Private Declare Sub PutMem4 Lib "msvbvm60" (ByVal Ptr As Long, ByVal Value As Long)
Private Function MrFrogInstrII(ByVal lngStart As Long, ByRef strString1 As String, ByRef strString2 As String) As Long
Dim lngLenS2 As Long, lngLenS1 As Long, lngLimit As Long
Dim lngAscHeader1(5) As Long, lngAscHeader2(5) As Long
Dim intAscS1() As Integer, intAscS2() As Integer
Dim Q As Long, C As Long
If lngStart > 0 Then
lngLenS2 = LenB(strString2) \ 2
If lngLenS2 > 0 Then
lngLenS1 = LenB(strString1) \ 2
lngLimit = lngLenS1 - lngLenS2 - 1
If lngLimit > 1 Then
lngAscHeader1(0) = &H1
lngAscHeader1(1) = &H2
lngAscHeader1(3) = StrPtr(strString1)
lngAscHeader1(4) = lngLenS1
PutMem4 ArrayPtr(intAscS1), VarPtr(lngAscHeader1(0))
lngAscHeader2(0) = &H1
lngAscHeader2(1) = &H2
lngAscHeader2(3) = StrPtr(strString2)
lngAscHeader2(4) = lngLenS2 + 1
PutMem4 ArrayPtr(intAscS2), VarPtr(lngAscHeader2(0))
Q = lngStart - 1
Do While Q < lngLimit
Do While intAscS1(Q + C) = intAscS2(C)
C = C + 1
If C = lngLenS2 Then
MrFrogInstrII = Q + 1
GoTo NullifyArr
End If
Loop
Q = Q + C + 1
C = 0
Loop
NullifyArr:
PutMem4 ArrayPtr(intAscS1), &H0
PutMem4 ArrayPtr(intAscS2), &H0
End If
End If
End If
End Function
Recordar quitar comprobación en los límites de arrays al compilar!
Debería haber tambien tests con cadenas laaaargas!
DoEvents!