aca les paso la clase que yo decia, que es mucho mas rapida que la de vbaccelerator y la que estoy usando actualmente.
Option Explicit
Option Compare Binary
Private Declare Sub RtlMoveMemory Lib "kernel32" (dst As Long, src As Long, ByVal nBytes&)
Private Declare Function SysAllocStringByteLen& Lib "oleaut32" (ByVal oleStr&, ByVal BLen&)
Private plngStringLen As Long
Private plngBufferLen As Long
Private pstrBuffer As String
Public Sub Append(Text As String)
Dim lngText As Long
Dim strTemp As String
Dim lngVPointr As Long
lngText = LenB(Text) \ 2&
If lngText > 0& Then
If (plngStringLen + lngText) > plngBufferLen Then
plngBufferLen = (plngStringLen + lngText) * 2&
'*** alternative strTemp = Space$(plngBufferLen)
RtlMoveMemory ByVal VarPtr(strTemp), SysAllocStringByteLen(0&, plngBufferLen + plngBufferLen), 4&
'strTemp = AllocString04(plngBufferLen)
'*** alternative Mid$(strTemp, 1&) = pstrBuffer
RtlMoveMemory ByVal (StrPtr(strTemp)), ByVal (StrPtr(pstrBuffer)), LenB(pstrBuffer)
'*** alternative pstrBuffer = strTemp
'*** (switch pointers)
lngVPointr = StrPtr(pstrBuffer)
RtlMoveMemory ByVal VarPtr(pstrBuffer), ByVal VarPtr(strTemp), 4&
RtlMoveMemory ByVal VarPtr(strTemp), lngVPointr, 4&
Debug.Print "plngBufferLen: " & plngBufferLen
End If
'*** Alternative Mid$(pstrBuffer, plngStringLen + 1&) = Text
RtlMoveMemory ByVal (StrPtr(pstrBuffer) + plngStringLen + plngStringLen), _
ByVal (StrPtr(Text)), lngText + lngText
plngStringLen = plngStringLen + lngText
End If
End Sub
Public Function Value() As String
'*** alternative Value = Left$(pstrBuffer, plngStringLen)
RtlMoveMemory ByVal VarPtr(Value), SysAllocStringByteLen(0&, plngStringLen + plngStringLen), 4&
RtlMoveMemory ByVal (StrPtr(Value)), _
ByVal (StrPtr(pstrBuffer)), plngStringLen + plngStringLen
End Function
Private Function AllocString04(ByVal lSize As Long) As String
' http://www.xbeat.net/vbspeed/
' by Jory, jory@joryanick.com, 20011023
RtlMoveMemory ByVal VarPtr(AllocString04), SysAllocStringByteLen(0&, lSize + lSize), 4&
End Function
Public Sub Clear()
'*** do not clear the buffer to save allocation time
'*** if you use the function multiple times
'*** and you have plenty of RAM.
plngStringLen = 0&
End Sub
Public Sub ClearBuffer()
'*** free memory
plngStringLen = 0&
plngBufferLen = 0& 'clear the buffer
pstrBuffer = vbNullString 'clear the buffer
End Sub
Private Sub Class_Initialize()
'*** paranoid
ClearBuffer
End Sub
la he comparado compilado con la tuya Psyke1, y es hasta 20 veces mas rapida, en un bucle de 100 mil iteraciones (con una cadena bastante larga) la tuya tarda mas de 2 segundos, mientras esta tarda 0.1 segundos
saludos.