Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default [need quick response] Read a line from a text file

    How do i read a line from a text file? i need to read a single line, msgbox what the line says and then do the same for the next line.

    +rep to helpers

  2. #2
    Join Date
    Apr 2007
    Posts
    675
    Tokens
    0

    Default

    What? If you mean find text Ctrl + F.
    547 :big_grin:



  3. #3
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    no ill try pseudo code it.

    Begin
    Read "hello.txt"
    Seperate lines
    Alert each line
    End

  4. #4
    Join Date
    Aug 2004
    Location
    UK
    Posts
    11,283
    Tokens
    2,031

    Latest Awards:

    Default

    In what language?

    Vb6 would be for exsample:
    Code:
    Private Sub getline_Click()
        'line to get
        getline = 8
        usefile = "C:\somefile.txt"
        'open file
        Open usefile For Input As #1
        curline = 1
        'loop till line found
        Do Until stopme Or EOF(1)
            Line Input #1, linetext
            'if this is the line stop looping and msgbox it
            If curline = getline Then
                stopme = True
                MsgBox linetext
            End If
            curline = curline + 1
        Loop
        Close #1
    End Sub
    Last edited by Mentor; 03-05-2007 at 07:29 PM.

  5. #5
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by 01101101entor View Post
    In what language?

    Vb6 would be for exsample:
    Code:
    Private Sub getline_Click()
        'line to get
        getline = 8
        usefile = "C:\somefile.txt"
        'open file
        Open usefile For Input As #1
        curline = 1
        'loop till line found
        Do Until stopme Or EOF(1)
            Line Input #1, linetext
            'if this is the line stop looping and msgbox it
            If curline = getline Then
                stopme = True
                MsgBox linetext
            End If
            curline = curline + 1
        Loop
        Close #1
    End Sub
    that should work cant test it at the moment because i haven't got vb 6 installed

Posting Permissions

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