fastest method to load text file

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
the listbox does sort the strings while inserting if sort is set to true
 
the listbox does sort the strings while inserting if sort is set to true
 
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
///
 
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

Back
Top