Solved

Writing sortedlist to textbox

Posted on 2004-08-09
6
361 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

948 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now