![]() |
ReadLine in Reverse
Is there a way to read a text file from the bottom up? I have a text file
that is going to get very big, and I am only interested in reading the bottom of the file. And I would like to reverse the order so that the last entry is displayed first. -- Thanks, Mike |
ReadLine in Reverse
How big is "very big"? Also, "displayed first" where? How many lines
represents "the bottom of the file"? If "very big" file is under, say, 10-15 Megs, this approach should work fine (15 to 50 Megs will work too; but speed, or lack thereof, may start to become a concern)... Sub GetEndOfFile() Dim X As Long Dim FileNum As Long Dim TotalFile As String Dim Records() As String FileNum = FreeFile Open "c:\temp\YourTextFile.txt" For Binary As #FileNum TotalFile = Space(LOF(FileNum)) Get #FileNum, , TotalFile Close #FileNum Records = Split(TotalFile, vbCrLf) ' ' At this point, the Records array contains each "paragraph", ' which I'm guessing would be your "entry"; just read it from ' last entry upward and put it wherever you want. Something ' like this (using a TextBox as your display vehicle)... ' ' For X = UBound(Records) To Ubound(Records) - 10 Step -1 ' TextBox1.Text = TextBox1.Text & vbCrLf & Records(x) ' Next End Sub Rick "Mike Archer" wrote in message ... Is there a way to read a text file from the bottom up? I have a text file that is going to get very big, and I am only interested in reading the bottom of the file. And I would like to reverse the order so that the last entry is displayed first. -- Thanks, Mike |
All times are GMT +1. The time now is 02:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com