Page 1 of 1

Opening and reading a text file line by line

Posted: Fri May 13, 2011 11:28 am
by Darren
Please Help!!!

Can anybody tell me how i can open a text file and read it "Line by Line"?

Here is my Visual Basic 6 example.... :

    Open "C:Test.txt" For Input As #1

    Do While Not Eof(1)
          Line Input #1, N$

          Msgbox N$
    Loop

    Close

Many thanks in advance!!!

Opening and reading a text file line by line

Posted: Wed May 25, 2011 6:15 am
by fred
You can use FileStream, something like this:

dim filenaam as string
dim f as FileStream
dim line as string

filenaam = "myfile.txt"

if FileExists(filename)=true then
  f.Open(filename)
  while f.Position < f.Size
    line=f.ReadLine
    showmessage line
  wend
  f.Close
end if