Option Explicit
Option Explicit
Private Sub Class_Initialize()
End Sub
Private Sub Class_Terminate()
End Sub
Public Property Get Text() As Variant
End Property
Public Property Let Text(ByVal vNewValue As Variant)
End Property
Public Property Get Delim() As Variant
End Property
Public Property Let Delim(ByVal vNewValue As Variant)
End Property
Public Function Add()
End Function
Public Property Get Text() As String
End Property
Public Property Let Text(ByVal strNewValue As String)
End Property
Public Property Get Delim() As String
End Property
Public Property Let Delim(ByVal strNewValue As String)
End Property
Public Function Add(ByVal strNewValue As String)
End Function
Option Explicit
Private colStrings As Collection
Private strDelim As String
Public Function Add(ByVal strNewValue As String)
colStrings.Add strNewValue
End Function
Public Property Get Delim() As String
Delim = strDelim
End Property
Public Property Let Delim(ByVal strNewValue As String)
strDelim = strNewValue
End Property
Public Property Get Text() As String
Dim lngNext As Long
Dim strStrings() As String
Dim varItem As Variant
Dim strText As String
Select Case colStrings.Count
Case 0
Text = vbNullString
Case 1
Text = colStrings(1)
Case Else
ReDim strStrings(1 To colStrings.Count)
For Each varItem In colStrings
lngNext = lngNext + 1
strStrings(lngNext) = varItem
Next
Set colStrings = Nothing
Set colStrings = New Collection
strText = Join(strStrings, strDelim)
colStrings.Add strText
Text = strText
End Select
End Property
Public Property Let Text(ByVal strNewValue As String)
Set colStrings = Nothing
Set colStrings = New Collection
colStrings.Add strNewValue
End Property
Private Sub Class_Initialize()
Set colStrings = New Collection
End Sub
Private Sub Class_Terminate()
Set colStrings = Nothing
End Sub
Public Sub testBuildString(ByVal parmIterations)
Dim lngLoop As Long
Const AtoZ As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim BS As New clsBuildString
For lngLoop = 1 To parmIterations
BS.Add AtoZ & Format(lngLoop, "0000000000")
Next
BS.Delim = vbCrLf
If Len(BS.Text) > 255 Then
Debug.Print "Length of concatenate string: " & Len(BS.Text)
Else
Debug.Print BS.Text
End If
End Sub
for each X in array(5,10,100,1000,10000,100000):?X,timer:testBuildString X:?X,timer:?:next
5 8625.439
ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000001
ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000002
ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000003
ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000004
ABCDEFGHIJKLMNOPQRSTUVWXYZ0000000005
5 8625.452
10 8625.456
Length of concatenate string: 378
10 8625.466
100 8625.47
Length of concatenate string: 3798
100 8625.484
1000 8625.489
Length of concatenate string: 37998
1000 8625.516
10000 8625.521
Length of concatenate string: 379998
10000 8625.673
100000 8625.678
Length of concatenate string: 3799998
100000 8626.904
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (3)
Commented:
Commented:
I liked it as well on a quick read. I will look to set aside some time to look in detail
Cheers
Dave
Author
Commented:http:/A_3802-Parent-Class-Builder-Add-In-for-Microsoft-Excel.html