jump directly to the line 457478

sorry for my bad English.

i have a text with 132 fixed length lines.

i need to jump directly to the line number 457478.

but not with the a loop line by line... i know this way, i need to jump directly the line  457478.

Now after the code is in line number 457478, read, line-by-line, the rest of text to the end of text

The text file has approx 4500000 (4.5M) lines and the file size is approx 533 MB
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Since these are fixed length lines, you have at least two solutions.
VB instrinsic solution 1
Open the file as Input
Calculate the position in the file = (record size * 457478)
Use the Seek statement to position the 'cursor' in the file
Use Line Input statement to read the rest of the file

VB instrinsic solution 2
Open the file as Binary or Random
Calculate the position in the file = (record size * 457478)
Use the Get statement to position the 'cursor' in the file
Use Get statement to read the rest of the file

FileSystemObject solution
Open the file and instantiate a textstream object
Calculate the position in the file = (record size * 457478)
Use the textstream's Skip method to position the 'cursor' in the file
Use textstream's readline method to read the rest of the file
tina2009Author Commented:
not for me....:-(

can you post a simple code for all ttree possible solution?
Do you know how to program/code?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

tina2009Author Commented:
Sure! but my knoledgment of vb6 not is so advanced:-)
With what programming languages are you familiar?

Have you pressed F1 and read the help text for the Open statement or Line Input statement or the Seek statement?

Have you done an online search of the FileSystemObject or the TextStream object?

can you post a simple code for all ttree possible solution?
While I could do that, I'm not going to.  I might post one, but I don't know the context/application in which you are coding.

Some effort on your part will go a long way when working with the experts.

The volunteer experts are here to help you.  If you need a professional to do all the work for you, look at the top experts in the VB zone and see if any of them have enabled their Hire Me link.
For example purposes, I've attached a sample fixed length file.  It only has 400 records.

The following routine accepts a starting record number as a parameter value and uses the Seek statement to position the 'cursor'.  Although each line is only 19 characters long, the length of the line used for calculating the offset, includes the vbCrLf characters that terminate/delimit the lines.
Option Explicit

Sub Q_28654444(parmStartLine As Long)
    Dim intFN As Integer
    Dim strLineData As String
    Const cRecLen As Long = 21
    intFN = FreeFile
    Open "c:\users\aikimark\downloads\Fixed Length Data.txt" For Input As #intFN
    Seek #intFN, (cRecLen * parmStartLine) + 1
    Do Until EOF(intFN)
        Line Input #intFN, strLineData
        Debug.Print Right(strLineData, 3), ;
End Sub

Open in new window

If you needed to read the line before you started looping, you would add an extra Line Input statement.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tina2009Author Commented:
No good devolution...
I don't understand your comment
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.