Language:

FastString - StringBuilder mit ASP

Language: Deutsch
Programming Language: VBScript
Published by: Thomas
Last Update: 4/27/2006
Views: 979

Description

Die VBScript-Klasse erledigt das, was im .NET-Framework der StringBuilder macht: Strings schnell zusammenfügen. Hilfreich wenn man viele Strings beispielsweise in einer Schleife verknüpft.

Code

1 '============================================================================== 2 Class FastString 'String-Join-Klasse 3 '============================================================================== 4 Dim stringArray,growthRate,numItems 5 6 Private Sub Class_Initialize() 7 growthRate = 50: numItems = 0 8 ReDim stringArray(growthRate) 9 End Sub 10 11 Public Sub Append(ByVal strValue) 12 ' Next line will prevent type mismatch errors if item is null. Performance hit is negligible 13 strValue=strValue & "" 14 If numItems > UBound(stringArray) Then ReDim Preserve stringArray(UBound(stringArray) + growthRate) 15 stringArray(numItems) = strValue:numItems = numItems + 1 16 End Sub 17 18 Public Sub Reset 19 Erase stringArray 20 Class_Initialize 21 End Sub 22 23 Public Function concat() 24 Redim Preserve stringArray(numItems) 25 concat = Join(stringArray, "") 26 End Function 27 End Class 28 '==============================================================================

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS