READ text file from the botton to the top..

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

READ text file from the botton to the top..

Post by sal21 »

I use the tipical:
Open "C:\TEMP\TABULATI_132.TXT" For Input As #1
ecc....

instead to read to the top > to the bottom i need to read from the botton to the top, possible?

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: READ text file from the botton to the top..

Post by HansV »

Turn the monitor upside down? :grin:

But seriously, the methods for reading a text file are optimized for reading forwards i.e. top to bottom.
You might read the lines into an array of strings, then loop backwards through the array.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: READ text file from the botton to the top..

Post by sal21 »

HansV wrote:Turn the monitor upside down? :grin:

But seriously, the methods for reading a text file are optimized for reading forwards i.e. top to bottom.
You might read the lines into an array of strings, then loop backwards through the array.
AHHHHHHHHHHHHHHH.... sure! :grin:

i ordering the filled array backwards when the code finish the regular reading?

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: READ text file from the botton to the top..

Post by HansV »

You don't have to order the array but you can read it backwards:

Code: Select all

  Dim i As Long
  For i = UBound(MyArray) To LBound(MyArray) Step -1
    ' process MyArray(i)
  Next i
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4355
Joined: 26 Apr 2010, 17:36

Re: READ text file from the botton to the top..

Post by sal21 »

HansV wrote:You don't have to order the array but you can read it backwards:

Code: Select all

  Dim i As Long
  For i = UBound(MyArray) To LBound(MyArray) Step -1
    ' process MyArray(i)
  Next i
I'M VERY STUPID!
Naturally the step -1 is wath i need!
tks! :laugh: :grin: :thankyou: