Solved

Writing sortedlist to textbox

Posted on 2004-08-09
6
365 Views
Last Modified: 2008-02-01
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
             Loop
0
Comment
Question by:martinjamesd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11755545
dim foo as object
dim tmpText as String
foreach foo in sortedList
    tmpText += foo.ToString() + vbCrLf
end for

MultiLineTextBox.Text = tmpText
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 250 total points
ID: 11755571
sorry

       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
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11755577
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
Next
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 11756752
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:)

Bob
0
 

Author Comment

by:martinjamesd
ID: 11773313
Thanks Greg that was perfect
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11773359
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 =

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question