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

Posted on 2003-10-27
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:


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

Question by:Jeremy Daley
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 86

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.
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)


Author Comment

by:Jeremy Daley
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
   myarray=split(thefile.ReadAll, vbNewLine)
   'myarray(n) is the first i only need to add and subtract from "n"

thanks anyway,
Technology Partners: 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.

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?

LVL 86

Expert Comment

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


Accepted Solution

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


Community Support Moderator
Experts Exchange

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question ( 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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

632 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