+ Reply to Thread
Results 1 to 4 of 4

Read Next Line for Check only

  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Read Next Line for Check only

    Hello Friends,

    I am reading text file and i just want to check what next line contain
    but cursor location should not change

    e.g.
    currently i am reading Line No. 5 (Using ReadLine Function)
    now i want to check what Line No. 6 contain
    after checking i want to read Line No. 6 (but my cursor location goes on 7th Line)

    In Short is it possible to move the current cursor (ReadLine) to Previous line
    In short i want to read a single Line twice (Move cursor Backward and forward)

    Here is my Code

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Read Next Line for Check only

    Quote Originally Posted by mohan.r1980 View Post
    In Short is it possible to move the current cursor (ReadLine) to Previous line
    In short i want to read a single Line twice (Move cursor Backward and forward)
    You cannot move the line pointer backwards in Open file For Input mode. It reads sequentially and forward.

    You could read each line and keep track of the previous line with another variable. Something like this...

    Please Login or Register  to view this content.
    Alternatively, you could Read the first line, Store the pointer position, Read the next line, close and reopen the same file. Then read up to the stored pointer position.

    Also, there are the two other modes; Open for Random Access and Binary. Both have advantages and disadvantages and are a little more complicated. Do a web search for something like VB File Access "Random Access" Binary mode for several useful step-by-step guides. This one looks helpful.
    FILE HANDLING USING VISUAL BASIC 6.0 PART I
    Last edited by AlphaFrog; 11-02-2012 at 12:04 PM.

  3. #3
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Read Next Line for Check only

    hi AlphFrog,

    i already tried this solution

  4. #4
    Registered User
    Join Date
    10-29-2012
    Location
    Bedfordshire, England
    MS-Off Ver
    Excel 2003
    Posts
    35

    Re: Read Next Line for Check only

    Hi Mohan.

    You could try reading the lines of the file into an array first.
    Then you could access any line at any time.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1