-
Jan 7th, 2015, 04:56 PM
#1
Thread Starter
New Member
reading an textfile to an array, and then sorting.
I have a text file that is populated with
08 name :tt
11 name :nn
07 name :kk
I would like the read the whole text file to an array, and then sort it, afterwards displaying it into a list box. i have tried
listArrays.Items.Clear()
Dim content As String
Dim lines As New ArrayList
Dim sr As System.IO.StreamReader
' read the file's lines into an ArrayList
Try
sr = New System.IO.StreamReader("G:\ControlleAssesmentClass\Class1.txt")
Do While sr.Peek() >= 0
lines.Add(sr.ReadLine())
Loop
lines.Sort()
lines.Reverse()
Finally
If Not sr Is Nothing Then sr.Close()
End Try
listArrays.Items.Clear()
listArrays.Sorted = True
listArrays.Items.AddRange(lines.ToArray)
End Sub
`
but it does not work, as it only sorts the file but doesnt display it in its reverse order. can anyone help please, thank you.
-
Jan 7th, 2015, 05:06 PM
#2
Re: reading an textfile to an array, and then sorting.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 7th, 2015, 05:07 PM
#3
Re: reading an textfile to an array, and then sorting.
I am closing the thread as you've already asked the question on this thread: http://www.vbforums.com/showthread.p...ting-the-array
Please do not post multiple threads.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|