Line Input # Statement

Line Input # filenumber and name

Reads a line from a sequential file into a String or Variant variable.

The parameter filenumber is used in the open statement to open the file. The parameter name is the name of a variable used to hold the line of text from the file.

Example:

' Line Input # Statement Example:

' This example uses the Line Input # statement to read a line from a

' sequential file and assign it to a variable. This example assumes that

' TESTFILE is a text file with a few lines of sample data.

 

Sub Main

   Open "TESTFILE" For Input As #1   ' Open file.

   Do While Not EOF(1)   ' Loop until end of file.

       Line Input #1, TextLine   ' Read line into variable.

       Print TextLine   ' Print to Debug window.

   Loop

   Close #1   ' Close file.

End Sub

 


Related Topics:

Open Statement