Improved String Concatenation Performance
Joining strings together, or concatentation, can take a toll on performance. Especially in a long loop. Here is a method to increase performance by 20x.
Sub Concat(Dest As String, Source As String)
'First Dest must have one space more
'Example : Dest = 'Hello '
'and not Dest = 'Hello'
Dim string1 As Long
Dim string2 As Long
string1 = Len(Dest)
string2 = Len(Source)
Dest = Dest & Space$(string2)
Mid$(Dest, string1, string2) = Source
End Sub
Special Instructions
This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.