読者です 読者をやめる 読者になる 読者になる

‥‥、え〜と、肝心のコードを持っていくのを忘れたので貼っておきますね。

' TStringListっぽいクラス
Public Class StringList
    Private ObjectList As New List(Of String)

    ' メソッド
    Public Function Add(ByVal s As String) As Integer
        Dim sBuff As String() = Split(s, vbCrLf)

        For i As Integer = sBuff.GetLowerBound(0) To sBuff.GetUpperBound(0)
            ObjectList.Add(sBuff(i))
        Next
        Return ObjectList.Count - 1
    End Function

    Public Sub Insert(ByVal Index As Integer, ByVal s As String)
        Dim sBuff As String() = Split(s, vbCrLf)

        For i As Integer = sBuff.GetUpperBound(0) To sBuff.GetLowerBound(0) Step -1
            ObjectList.Insert(Index, sBuff(i))
        Next
    End Sub

    Public Sub Delete(ByVal Index As Integer)
        ObjectList.RemoveAt(Index)
    End Sub

    Public Sub Clear()
        ObjectList.Clear()
    End Sub

    Public Sub Exchange(ByVal Index1 As Integer, ByVal Index2 As Integer)
        Dim sBuff As String
        sBuff = ObjectList(Index1)
        ObjectList(Index1) = ObjectList(Index2)
        ObjectList(Index2) = sBuff
    End Sub

    Public Function IndexOf(ByVal s As String) As Integer
        Return ObjectList.IndexOf(s)
    End Function

    Public Sub Sort()
        ObjectList.Sort()
    End Sub

    ' Unicodeで文字列をファイルに保存
    Public Sub SaveToFile(ByVal FileName As String)
        Dim sw As New System.IO.StreamWriter(FileName, False)
        '内容をすべて書き込む
        sw.Write(Me.Text)
        '閉じる
        sw.Close()
    End Sub

    ' 文字コードを指定して文字列をファイルに保存
    Public Sub SaveToFile(ByVal FileName As String, _
                          ByVal encoding As System.Text.Encoding)
        Dim sw As New System.IO.StreamWriter(FileName, False, encoding)
        '内容をすべて書き込む
        sw.Write(Me.Text)
        '閉じる
        sw.Close()
    End Sub

    ' Unicodeで文字列をファイルから読み出し
    Public Sub LoadFromFile(ByVal FileName As String)
        Dim sr As New System.IO.StreamReader(FileName)
        '内容をすべて読み込む
        Me.Text = sr.ReadToEnd()
        '閉じる
        sr.Close()
    End Sub

    ' 文字コードを指定して文字列をファイルから読み出し
    Public Sub LoadFromFile(ByVal FileName As String, _
                            ByVal encoding As System.Text.Encoding)
        Dim sr As New System.IO.StreamReader(FileName, encoding)
        '内容をすべて読み込む
        Me.Text = sr.ReadToEnd()
        '閉じる
        sr.Close()
    End Sub

    ' プロパティ
    Default Public Property Item(ByVal index As Integer) As String
        Get
            Return ObjectList(index)
        End Get
        Set(ByVal value As String)
            ObjectList(index) = value
        End Set
    End Property

    Public ReadOnly Property Count As Integer
        Get
            Return ObjectList.Count
        End Get
    End Property

    Public Property Text As String
        Get
            Dim sBuff As String
            sBuff = ""
            For i As Integer = 0 To ObjectList.Count - 1
                sBuff = sBuff + ObjectList(i) + vbCrLf
            Next
            Return sBuff
        End Get
        Set(ByVal value As String)
            Dim sBuff As String() = Split(value, vbCrLf)
            ObjectList.Clear()
            For i As Integer = sBuff.GetLowerBound(0) To sBuff.GetUpperBound(0)
                ObjectList.Add(sBuff(i))
            Next
        End Set
    End Property

    Public Property CommaText As String
        Get
            Dim sBuff As String
            sBuff = ""
            For i As Integer = 0 To ObjectList.Count - 1
                sBuff = sBuff + ObjectList(i) + ","
            Next
            sBuff = sBuff.TrimEnd(",")
            Return sBuff
        End Get
        Set(ByVal value As String)
            Dim sBuff As String() = Split(value, ",")
            ObjectList.Clear()
            For i As Integer = sBuff.GetLowerBound(0) To sBuff.GetUpperBound(0)
                ObjectList.Add(sBuff(i))
            Next
        End Set
    End Property
End Class