Solved

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

Posted on 2003-10-27
8
152 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
[X]
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
8 Comments
 
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.
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 86

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

751 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