fastest method to load text file

G

Guest

what is the fastest method to sort and load 1 lakh + strings in a list box
from a text file. each string is in a new line
 
C

Cor Ligthert

Gaurav,
what is the fastest method to sort and load

It is not possible to sort a standard textfile at least there has to be
something what can be the sortkey.

Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
It is not possible to sort a standard textfile at least there has to be
something what can be the sortkey.

Huh?

You can sort the lines alphabetically:

\\\
Dim sr As New StreamReader("C:\WINDOWS\win.ini")
Dim Lines() As String = Split(sr.ReadToEnd, ControlChars.NewLine)
sr.Close()
Array.Sort(Lines)
For Each Line As String In Lines
Debug.WriteLine(Line)
Next Line
///
 
C

Cor Ligthert

Herfried,

I tried your code with a little change, what is the sense of this result.

///
\\\
Array.Sort(Lines)
Dim Lines() As String = Split(sr.ReadToEnd, ControlChars.NewLine)
Dim sr As New StreamReader("C:\Test\Herfrieds.txt")
For Each Line As String In Lines
M V P <URL:http://dotnet.mvps.org/>
Next Line
sr.Close()
You can sort the lines alphabetically:

Please, read my message again

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top