-
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.
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
|