"Chris" <No****@NoSpam.com> wrote in message
news:OX**************@TK2MSFTNGP14.phx.gbl...
You could do a couple different things. One is to run through the file
but don't save the contents to get a count.
Do Until sReader.Peek = -1
i = i + 1
sReader.ReadLine
Loop
Depending what you are doing with the data after you could use an array
list, it allows you to grow an array as you need it.
Dim MyArray as new Arraylist
Do Until sReader.Peek = -1
i = i + 1
MyArray.Add(sReader.ReadLine)
Loop
You could also just read the file in all at once.
Dim S as String = sReader.ReadToEnd()
Hope it helps
Thanx.
I am using ReDim Preserve to grow the array as the lines are read, but that
is not very efficient.
I had hoped that there was a count property somewhere.
In this app, the arrays are rather small, so the overhead of ReDim Preserve
should not be noticeable.
For larger arrays, the choices seem to be to make a separate pass to count
the lines, or to grow the array with ArrayList. Not sure which would be
faster.
In any case, I do not want to use Arraylists instead of normal arrays,
unless I can see an advantage.
--
http://www.standards.com/; See Howard Kaikow's web site.