StringBuffer

使い方

Public Sub Test()
   
    Dim xxxxx As New StringBuffer
    
    xxxxx.Append "A"
    xxxxx.Append "B"
    xxxxx.Append "C"
    
    Call MsgBox(xxxxx.ToString())
    
End Sub

コード

Option Explicit

Private Count As Long
Private Buffer() As String

'=======================================
'   Initialize / Terminate
'=======================================
Private Sub Class_Initialize()
    
    Call Clear

End Sub

'=======================================
'   Public Method
'=======================================
Public Sub Append(ByVal Text As String)

    If Count > UBound(Buffer) Then
        ReDim Preserve Buffer(UBound(Buffer) * 2)
    End If
    
    Buffer(Count) = Text
    Count = Count + 1

End Sub

Public Sub AppendLine(ByVal Text As String)
    
    Call Append(Text & vbCrLf)

End Sub

Public Sub Clear()
    
    Count = 0
    ReDim Buffer(16)

End Sub

Public Function ToString() As String
    
    ToString = Join(Buffer, "")

End Function

  • 最終更新:2012-08-27 19:42:15

このWIKIを編集するにはパスワード入力が必要です

認証パスワード