Solved

Writing sortedlist to textbox

Posted on 2004-08-09
6
355 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

13 Experts available now in Live!

Get 1:1 Help Now