Solved

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

Posted on 2003-10-27
8
139 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 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