Example - Line Input # Statement

This example assumes that TESTFILE.txt is a text file on you D drive with a few lines of sample data. The example uses the Line Input # statement to sequentially read each line from the file and assign it to a variable.


Sub Main()
   Open "D:\TESTFILE.txt" For Input As #1 ' Open file.
   Do While Not EOF(1) ' Loop until end of file.
      Line Input #1, TextLine ' Read line into variable.
      MsgBox TextLine ' Display a message box for each line.
   Loop
   Close #1 ' Close file.
End Sub