Library tutorials & articles
String Concatenation Component
By Michael Balloni, published on 08 Oct 2001
Page 5 of 5
- Introduction
- The solution
- The results
- Conclusion
- Test Code
Test Code
The following is the test code used to generate the performance results displayed earlier in this article.
Private Sub TestCat()
Dim test_str As String
test_str = "foo foo bar"
TestCatFor 1, test_str
TestCatFor 5, test_str
TestCatFor 10, test_str
TestCatFor 25, test_str
TestCatFor 50, test_str
TestCatFor 100, test_str
TestCatFor 200, test_str
TestCatFor 500, test_str
TestCatFor 1000, test_str
TestCatFor 2000, test_str
'TestCatFor 5000, test_str
'TestCatFor 10000, test_str
test_str = "asd;fjas;dlfu =8-081254j kuva nfajoiruawior "
TestCatFor 1, test_str
TestCatFor 5, test_str
TestCatFor 10, test_str
TestCatFor 25, test_str
TestCatFor 50, test_str
TestCatFor 100, test_str
TestCatFor 200, test_str
TestCatFor 500, test_str
TestCatFor 1000, test_str
TestCatFor 2000, test_str
'TestCatFor 5000, test_str
'TestCatFor 10000, test_str
test_str = "asd;fjas;dlfu =8-081254j kuva nfajoiruawior " _
|
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by shane124 (4 replies)
-
Making the conversion from Visual Basic to .NET
by JimiJ (1 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
How to create a games like FIFA08
by mawcot (0 replies)
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
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
This thread is for discussions of String Concatenation Component.