CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2001
    Posts
    29

    Reading Line by line

    I want to read Line by Line from a txt file useing the FileSystemObject. When i use .ReadLine
    my string still contains all of what was in the txt file. Once i get one line i want to write it to another file and then go back the txt file to read a new line. Any Ideas??

    [email protected]


  2. #2
    Join Date
    Jul 2000
    Posts
    124

    Re: Reading Line by line

    Can we see the code?


  3. #3
    Join Date
    Apr 2001
    Posts
    29

    Re: Reading Line by line


    private Sub cmdReadFile_Click()
    Dim InStream as TextStream

    BodyText = App.Path & "\body.txt"
    set InStream = FSys.OpenTextFile(BodyText, 1, false, false)
    While InStream.AtEndOfStream = false
    TLine = InStream.ReadAll
    strBody = strBody & TLine & vbCrLf
    Wend
    ' Text1.Text = strBody
    set InStream = nothing

    Dim AddressInStream as TextStream

    AddressText = App.Path & "\email.txt"
    set AddressInStream = FSys.OpenTextFile(AddressText, 1, false, false)
    While AddressInStream.AtEndOfStream = false
    TLine = AddressInStream.ReadLine
    strAddress = strAddress & TLine & vbCrLf
    Wend
    Text1.Text = strAddress & strBody
    set AddressInStream = nothing
    End Sub





  4. #4
    Join Date
    Apr 2001
    Posts
    29

    Re: Reading Line by line

    email.txt
    looks like this

    [email protected]
    [email protected]

    with about 200 address.


  5. #5
    Join Date
    Jul 2000
    Posts
    124

    Re: Reading Line by line

    Every time you say this:

    strAddress = strAddress & TLine & vbCrLf

    It is appending the new stuff to the old stuff. You need to just use:

    strAddress = TLine & vbCrLf

    HTH,
    Erica


  6. #6
    Join Date
    Apr 2001
    Posts
    29

    Re: Reading Line by line

    strAddress = TLine & vbCrLf

    This only gives me the last line in the email.txt.



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

Featured