# jump directly to the line 457478

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

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

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

Commented:
@tina2009

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
0
Author Commented:
not for me....:-(

can you post a simple code for all ttree possible solution?
Tks.
0
Commented:
Do you know how to program/code?
0
Author Commented:
Sure! but my knoledgment of vb6 not is so advanced:-)
0
Commented:
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.
0
Commented:
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
Seek #intFN, (cRecLen * parmStartLine) + 1
Do Until EOF(intFN)
Line Input #intFN, strLineData
Debug.Print Right(strLineData, 3), ;
Loop
Debug.Print
Close
End Sub
``````
If you needed to read the line before you started looping, you would add an extra Line Input statement.
Fixed-Length-Data.txt
0

Experts Exchange Solution brought to you by

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

Author Commented:
No good devolution...
blahhnh
0
Commented: