?
Solved

Writing sortedlist to textbox

Posted on 2004-08-09
6
Medium Priority
?
370 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 1000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

801 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