+ Reply to Thread
Results 1 to 7 of 7

Read next Line

  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

    Hi friends,
    i have a text file and i want to read each line and parse the word and put it in to variable field
    but when "while looping process" i want to read next line for condition.
    i want to put variable Add1, Add2, Add3, Reg.No, Name2.
    Problem is that when i ReadLine contain "Address" then i parse Add1 but Add2, Add3 is optional so i want to know when ReadLine read the current line that time Nextline contain "[" this sign or not if "NO" then it will put in Add2, if "YES" then don't go to Add2 and Add3

    For more detail i also attached Sample text file and also put the code which i done

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mohan.r1980; 12-10-2010 at 06:51 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Read next Line

    Hi mohan.r1980
    One way would be to look at each line and set the boolean to find the start and finish lines to print
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  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

    thanks pike for reply
    right now i am trying your code, but before trying your code
    i would like to ask you can i read the next line "while looping"
    .

    is this possible?

    Because this is a one sample i provided but further i want to use the condition

    if this is possible then it makes me very easy to make all the variable field.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Read next Line

    Hi mohan.r1980
    You can read two lines at once with
    Please Login or Register  to view this content.

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Read next Line

    or a loop with in loop
    Please Login or Register  to view this content.

  6. #6
    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

    instead of debug.print can i put the variable in sAdd1,sAdd2?

    Please Login or Register  to view this content.
    And

    Please Login or Register  to view this content.
    because Debug.Print show the read line in immediate window.

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Read next Line

    Hi mohan.r1980
    I only use debug.print so i can easily see the result so you can add then to a varables.
    or add them to an arraray then split them into different variables

    Better add "And Not EOF(FN)" to this line
    Please Login or Register  to view this content.
    to trap errors

+ 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