Unless they've changed something in the last decade :-)
You're probably opening the textfile as a "stream of data" in which case you
must read forward. That leaves you with one of two solutions (in my mind.)
If the data isn't going to change as you are reading it you can make two
passes. The first one is to count how many lines you have, then you rewind
and skip as many lines as needed until you get to the point where 20 remain.
Append those to a collection and reverse the order just prior to using it.
The other method permits you to make a single pass but it means you will
store each line into a collection that contains a maximum of 20 items. Each
time you are about to store a new one you see if there are 20 and if so
delete the earliest one. At the end you will have a maximum of 20 items in
the collection. Reverse the order as above.
There is actually a third method. Simply read ever line into the
collection, reverse the order and limit the number of items you display.
Tom
"Stupid48" <cf*****@hotmai l.comwrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com...
I'm trying to do a simple task but can't seem to find a solution. How
do I read lines from a text file backwards.
i.e. I want to select the last 20 lines of a text file and display them
in order starting with the last line first.....
Any assistance would be greatly appreciated....
Thanks, Chris