Solved

is it possible to read previous line in a text document?

Posted on 2003-10-27
8
146 Views
Last Modified: 2010-05-01
my text file works like a database except it can't be sorted. but i read each line when i click a "next" button using:

  thefile.Readline

is there a way to go back a line when i click on a "previous" button?

thanks,
jeremy
0
Comment
Question by:daleyjem
8 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9628541
Most likely you have opened the file in sequential mode and cannot do that.  You can open the file in Random mode, but this requires that the data be written to it as records with predefined fields lengths, etc....

Alternatively, your could close the file, reopen it, and then count down to the line just before your previous location.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9628709
A WAG, but perhaps you can use the Skip method with negative characters.  Of course that would assume you kept tabs as to where you were and the length of the last/previous line(s)

Anthony
0
 
LVL 4

Author Comment

by:daleyjem
ID: 9628801
i'll have to cancel this question if i don't find an obvious way cause i just figured a way out using an array:

   dim myarray() as string, n
   n=0
   myarray=split(thefile.ReadAll, vbNewLine)
   
   'myarray(n) is the first line...now i only need to add and subtract from "n"

thanks anyway,
jeremy
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9628891
No problem.

Anthony
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9631260
Need some help getting this question deleted and your 25 points refunded?

I answered my question myself. What do I do?
http://www.experts-exchange.com/help/closing.jsp#4

Anthony
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10164858
Refund is his points as he figured out a way himself.

Idle_Mind
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10167070
PAQ'd and 25 points refunded.

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question