borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Improve String Concatenation Performance

Author  

Zeljko Bijelic

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
Tip
'          ========================================
'
'           20 times Faster
'
'          VB work for concatenation
'          =========================
'          1. Allocates temporary memory large enough to hold the result.
'          2. Copies Dest to the start of the temporary area.
'          3. Copies Source to the end of the temporary area.
'          4. De-allocates the old copy of Dest.
'          5. Allocates memory for Dest large enough to hold the result.
'          6. Copies the temporary data to Dest.
          
          
'          Faster Concatenation
'          ====================
          
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
:: Navigation

Home

Miscellaneous Tips

Previous Tip

Next Tip

:: Search this site
Google
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder