Line Input # (statement)

<< Click to Display Table of Contents >>

Line Input # (statement)

Line Input [#]FileNumber, Name

Reads a line from a file and stores the result in the string or Variant variable Name.

FileNumber is the number assigned to the file by the Open statement. The file must have been opened with the command Open for reading beforehand.

The statement Line Input reads the characters from the file until a line feed (LF) or a combination of carriage return + line feed (CR+LF) is encountered.

See also: Input, Open, Seek

Example:

Sub Main

 Open "c:\autoexec.bat" For Input As #1          ' Open file

 While Not EOF(1)                         ' Repeat until end of file

         Line Input #1, TextLine               ' Read line from file

         Print TextLine                        ' Output line

 Wend

 Close #1                                 ' Close file

End Sub