Solved

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

Posted on 2003-10-27
8
135 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
No problem.

Anthony
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
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
Comment Utility
Refund is his points as he figured out a way himself.

Idle_Mind
0
 

Accepted Solution

by:
modulo earned 0 total points
Comment Utility
PAQ'd and 25 points refunded.

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now