Search code examples
vbscriptreadlinefilesystemobject

Is there a way to set the starting read line in vbscript?


I have a text file and it has more than 85k lines Is there a way to set the starting line? For example; I've already read and write the lines 1-10 to other file and want to get a value in line 12 to add it in the last line that I wrote. I want to read only the line 12.

  1. Text/Sample/1/GetValue/12
  2. Text/Sample/2/GetValue/11
  3. Text/Sample/3/GetValue/10
  4. Text/Sample/4/GetValue/9
  5. Text/Sample/5/GetValue/8
  6. Text/Sample/6/GetValue/7
  7. Text/Sample/7/GetValue/6
  8. Text/Sample/8/GetValue/5
  9. Text/Sample/9/GetValue/4
  10. Text/Sample/10/GetValue/3
  11. Text/Sample/11/GetValue/2
  12. Text/Sample/12/GetValue/1

Solution

  • The TextStream object provides sequential forward reading only. See the Docs for .Skip, .SkipLine, .Read, .ReadLine, and .ReadAll.

    So you have to skip/read to the desired position, or do some Mid string work on the full content (.Readall) of the file.