I've had this code lying around, so thought I would post it here.
It is ( well, should be) a lot faster than VB's internal string appending & operator.
VB Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Sub appendToString(ByRef strBuff As String, ByVal strStringToAppend As String) CopyMemory ByVal StrPtr(strBuff) + LenB(strBuff), ByVal StrPtr(strStringToAppend), LenB(strStringToAppend) End Sub '' Sample Usage '' Private Sub Form_Load() Dim i As Long, x As String: x = "a" For i = 0 To 10000 appendToString x, CStr(i) Next MsgBox x End Sub




) a lot faster than VB's internal string appending & operator.
Reply With Quote