Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to skip a few lines while reading from a text file?

How to skip a few lines while reading from a text file?

Scheduled Pinned Locked Moved Visual Basic
performancehelptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ESJY
    wrote on last edited by
    #1

    i m currently working on a program which is able to read a text file. however, i have encountered this problem while extracting information from the text. first i have to reach a keyword found in the text (which i have successfully implemented), then i have to skip a few lines after the keyword to extract the useful information. i have no idea on how to skip the lines while the program is reading the information from the file. i think it is not wise to load everything into the program, which takes up memory, and discard. could anyone suggest on how to ignore the useless information? Thanks. Esther

    A 1 Reply Last reply
    0
    • E ESJY

      i m currently working on a program which is able to read a text file. however, i have encountered this problem while extracting information from the text. first i have to reach a keyword found in the text (which i have successfully implemented), then i have to skip a few lines after the keyword to extract the useful information. i have no idea on how to skip the lines while the program is reading the information from the file. i think it is not wise to load everything into the program, which takes up memory, and discard. could anyone suggest on how to ignore the useless information? Thanks. Esther

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      Simple. Just read the line, or lines, you want to skip and don't do anything with them. You'll probably want to read the exact number of lines you want to skip inside a for/next loop.

      Dim strDiscard as String
      For x = 1 to n
      strDiscard = ReadLine(filepointer) ' or whatever your using to read a line from the file
      Next

      E 1 Reply Last reply
      0
      • A Anonymous

        Simple. Just read the line, or lines, you want to skip and don't do anything with them. You'll probably want to read the exact number of lines you want to skip inside a for/next loop.

        Dim strDiscard as String
        For x = 1 to n
        strDiscard = ReadLine(filepointer) ' or whatever your using to read a line from the file
        Next

        E Offline
        E Offline
        ESJY
        wrote on last edited by
        #3

        thanks... i will try this out.. but i have found another command called 'SkipLine', does it help?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups