Library tutorials & articles

String Concatenation Component

Conclusion

When you need to concatenate more than a few dozen strings, consider using StrCat.Catter. Catter's optimized C++ implementation can prevent your site from CPU saturation when folks start asking more of it than VB can handle.

Download the source code in ZIP format

Happy Programming!

Comments

  1. 06 Jun 2003 at 00:17

    A great idea!  You can also reduce concatenation times by using arrays and the built-in Join() function.  No components required.  Similar performance gain.  Very readable syntax (once you understand the Join arguments).  


    StringVar = JOIN( StringArray(), ElementSeparatorText )


    Redim S(4)
    S(0) = "This is text line 1"
    S(1) = "This is text line 2"
    S(2) = "This is text line 3"
    S(3) = "This is text line 4"
    S(4) = "This is text line 5"


     'assign lines to string variable with comma separator


    vMyString = join(S, ",")


     'dump lines to screen, one element per visual line ("&" executes once)


    response.write join(S, "<br>" & VbCrLf)


     'output array as a table row (elements are separated with "</td><td>")


    response.write "<tr><td>" & join(S, "</td><td>" ) & "</td></tr>"


     'build an option list of codes that exist in a database


    set rs = CreateObject("ADOR.Recordset")
    rs.Open "select [TypeCode] from [CodeTable] order by [TypeCode]", myConnectString, adOpenStatic
    S = rs.getrows '<-- very fast!
    rs.close
    response.write = "<select ...>" & vbcrlf
    response.write = "<option>" & join(S, "</option>" & vbcrlf & "<option>" ) & "</option>" & vbcrlf
    response.write = "</select>" & vbcrlf


     'clear array from memory (if you want to free up memory right away)


    erase S

  2. 01 Jan 1999 at 00:00

    This thread is for discussions of String Concatenation Component.

Leave a comment

Sign in or Join us (it's free).

Michael Balloni

We'd love to hear what you think! Submit ideas or give us feedback