VB icon

CStrCat v. 1.1

Email
Submitted on: 1/5/2015 4:26:00 PM
By: Neil McGuigan (from psc cd)  
Level: Advanced
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages)
Views: 1493
 
     Faster version of StrCat posted by someone else. About 2x faster. About 6x faster than '& (ampersand)' operator for many concatenations.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :CStrCat v. 1.1
'**************************************
Copyright (c) 2001, Neil McGuigan. All rights reserved. This software is licensed.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: CStrCat v. 1.1
' Description:Faster version of StrCat posted by someone else. About 2x faster. About 6x faster than '& (ampersand)' operator for many concatenations.
' By: Neil McGuigan (from psc cd)
'
' Inputs:Does not need length property as it will increase the array size by 10% if it maxes out. 
.add strPart
'
' Returns:.value ~ whole string
'
' Assumes:dim sc
set sc=new CStrCat
for i=0 to 10000
 sc.add "whatever"
next
response.write sc.value
'**************************************

<%
Class CStrCat //v1.1
	Private i,sa()
	Public Property Get Value
		redim preserve sa(i)
		Value=Join(sa,"")
	End Property 
	Private Sub Class_Initialize()
		i=clng(0)
		redim sa(500)
	End Sub
	private sub class_terminate()
		erase sa
	end sub
	Public function Add(ps)
		if len(ps)=0 then exit function
		if (i>=ubound(sa)) then upsize
		sa(i)=ps
		i=i+1
	End function
	private sub upsize()
		dim u
		u=ubound(sa)
		redim preserve sa(clng(u+u*0.1))
	end sub
End Class 
%>


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.