Writing sortedlist to textbox

I have the following code which reads in a text file and parses it, writing the values to a sortedlist. How can I write these values to a multiline textbox after reading and parsing the complete file. Each line in the sortedlist must be on a separate line in the textbox.

Dim sortedList As SortedList = New SortedList(max)
Dim sr As StreamReader = New StreamReader(filePath)
            Dim strBroadcastRecord As String
            ' Check for End Of File
            Do While sr.Peek >= 0
                'If not End Of File read the next line
                strBroadcastRecord = sr.ReadLine
                'Parse the line
                objBroadcastFile = Mid(strBroadcastRecord, 1, 7) & " - " & Mid(strBroadcastRecord, 27, 2) & Mid(strBroadcastRecord, 47, 3)
                'Add it to the list
                sortedList(objBroadcastFile) = objBroadcastFile
Who is Participating?
gregoryyoungConnect With a Mentor Commented:

       Dim myValueList As IList = sortedList.GetValueList()
        Dim i As Integer
        For i = 0 To sortedList.Count - 1
            tmpText += myValueList(i) + vbCrLf
        Next i

       MultiLineTextBox.Text = tmpText
dim foo as object
dim tmpText as String
foreach foo in sortedList
    tmpText += foo.ToString() + vbCrLf
end for

MultiLineTextBox.Text = tmpText
You could try something like this:

For ii As Integer = 0 to sortedList.Count-1
      TextBox.Text &= Ctype(sortedList.Item(ii), String)
      If ii < sortedList.Count -1 Then
            TextBox.Text &= Environment.Newline
      End If
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Bob LearnedCommented:
Kudos to Greg (a sound of applause can be heard from the bench players)

Put me in coach.  I can take 'em.  But, alas, too old and too slow:)

martinjamesdAuthor Commented:
Thanks Greg that was perfect
anytime glad to help ... btw a quick bonus ... that will work for an arraylist, hashtable, collection etc :)

just set it at the line as IList =

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.