read a specific line in txt file
-
- PlatinumLounger
- Posts: 4402
- Joined: 26 Apr 2010, 17:36
read a specific line in txt file
I need to read specific line in a txt file... for eample third line?
-
- Administrator
- Posts: 78794
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: read a specific line in txt file
Option 1:
Open the text file for input.
Loop from 1 to the specific number, read each line into a variable.
You end up with the desired line.
Option 2:
Open the text file for input.
Read the entire file into a variable.
Use Split with delimiter vbCrLf to create an array of lines.
To get the n-th line, get element n-1 of the array (it starts at 0).
Open the text file for input.
Loop from 1 to the specific number, read each line into a variable.
You end up with the desired line.
Option 2:
Open the text file for input.
Read the entire file into a variable.
Use Split with delimiter vbCrLf to create an array of lines.
To get the n-th line, get element n-1 of the array (it starts at 0).
Best wishes,
Hans
Hans