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.
Re: reading an textfile to an array, and then sorting.
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.