Results 1 to 7 of 7

Thread: Read Multiple lines [Resolved]

  1. #1

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143

    Question Read Multiple lines [Resolved]

    Hi,

    If I have a textfile with, for an example, 3 different lines, how can I read that lines and put them in 3 different textboxes per line.

    thnx
    Last edited by Rogier; Nov 22nd, 2004 at 08:55 AM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    do you want to put each line into a textbox by itself, or do you want to split each line into 3 different textboxes? Post an example of what you have, and what you want.

  3. #3

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143
    I want to put each line into a textbox by itself.
    Thanks for replay!

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    Code:
    Dim TestLine
    Dim Counter As Integer
    Counter = 1
    Open "Testfile" For Input As #1
    Do While Not EOF(1)
      Line Input #1, TestLine
      select case Counter
      case 1
        Textbox1.Text = TestLine
      case 2
        Textbox2.Text = TestLine
      case 3
        Textbox3.Text = TestLine
      End Select
      Counter = Counter + 1
    Loop
    Close #1
    Assumes that there are only 3 lines in the file.
    Substitute the name of your textboxes in the select statement.
    Last edited by dglienna; Nov 21st, 2004 at 06:22 PM.

  5. #5

    Thread Starter
    Addicted Member Rogier's Avatar
    Join Date
    Jun 2004
    Location
    Netherlands
    Posts
    143
    It works!
    Thank you very much!

    Greetings Roger

  6. #6
    Lively Member
    Join Date
    Nov 2004
    Posts
    73
    Hi dglienna,

    Can you help me to figure out the following issue:

    Does VB has any method to get the total line count before loop to read each line? I want to use progressBar control to give the processing percentage of the file. (the lines in file is read one line by one line). To use the ProgressBar control, have to know the total line count and assign the value to the Max property of ProgressBar. Have any advice?

    Thanks,

    Robert Song

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    not unless you save the total first when you are writing the file. then you can read the total, and then loop from there. I do that for a bunch of items that can be changed, yet the program can still deal with them all.

    Or, you could compute 25% and display that, then 50% from within the loop that is reading the info.

Posting Permissions

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



Click Here to Expand Forum to Full Width