For example...
Number_of_line=5000
Read TXT from Lines Number 5001, to the and of file
Read a text file from a specific line at to the and
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Read a text file from a specific line at to the and
Loop through the file line by line, and simply don't do anything with the first 5000 lines.
Code: Select all
Dim f As Integer
Dim i As Long
Dim s As String
f = FreeFile
Open "..." For Input As #f
Do While Not EOF(f)
Line Input #f, s
i = i + 1
If i > 5000 Then
' do something with s
End If
Loop
Close #f
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: Read a text file from a specific line at to the and
HERE: Line Input #f, sHansV wrote: ↑02 Dec 2021, 21:25Loop through the file line by line, and simply don't do anything with the first 5000 lines.
Code: Select all
Dim f As Integer Dim i As Long Dim s As String f = FreeFile Open "..." For Input As #f Do While Not EOF(f) Line Input #f, s i = i + 1 If i > 5000 Then ' do something with s End If Loop Close #f
Error in image
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Read a text file from a specific line at to the and
Is the text file a single line, perhaps?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Read a text file from a specific line at to the and
It probably has to do with the rest of your code. The code listed above should not cause problems.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: Read a text file from a specific line at to the and
The test1 Is a cut and past from original big file.
The big file Is stored in the dir, refered To the error in this post.
But i have maked An esperiment...
I loop the big file wiht a fso stream And dont have error!
Peraph each Lines in file dont have a crlf on each line....
No idea.
The big file Is stored in the dir, refered To the error in this post.
But i have maked An esperiment...
I loop the big file wiht a fso stream And dont have error!
Peraph each Lines in file dont have a crlf on each line....
No idea.
-
- Administrator
- Posts: 78493
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Read a text file from a specific line at to the and
There is a CrLf at the end of every line in the small file that you attached.
But you could use the same idea for the FSO Stream.
But you could use the same idea for the FSO Stream.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36