Thanks to the wonderful teams of people at Stack Overflow, here is the following code that has been created. It works wonderfully, except for an error at the end that I cannot debunk.
Class:
Private m_arrBuffer
Private m_strDelimiter
Private Sub Class_Initialize()
m_arrBuffer = Array()
m_strDelimiter = “”
End Sub
Private Sub Class_Terminate()
m_arrBuffer = Empty
End Sub
Public Property Get Delimiter()
Delimiter = m_strDelimiter
End Property
Public Property Let Delimiter(strDelimiter)
m_strDelimiter = strDelimiter
End Property
Public Sub Append(strValue)
ReDim Preserve m_arrBuffer(UBound(m_arrBuffer) + 1)
m_arrBuffer(UBound(m_arrBuffer)) = strValue
End Sub
Public Sub AppendLine(strValue)
Me.Append strValue & vbCrLf
End Sub
Public Sub Compact()
If Not Me.Delimiter = “” Then
strOriginalDelimiter = Me.Delimiter
Me.Delimiter = “”
End If
strTemp = Me.ToString
m_arrBuffer = Array()
Me.Append strTemp
Me.Delimiter = strOriginalDelimiter
End Sub
Public Function ToArray()
ToArray = m_arrBuffer
End Function
Public Function ToString()
ToString = Join(m_arrBuffer, m_strDelimiter)
End Function
Code (credit to @Bond)
Dim sb
Set sb = New StringBuilder ' Guessing here. You haven't shown the class name.
sb.Append "some string"
sb.Append "another string"
sb.Append "a third string"
....
sb.Delimiter = "<br>"
myHtmlFile.Write sb.ToString()
I am recieving an error at myHtmlFile.Write sb.ToString() Run-time error '424': Object required.
I am not sure but I believe this is the final hurdle before I have a working code. Any advice on how to alleviate this error? Thank you.
myHtmlFileobject has not been created. Can you call other methods/properties on that object properly?