Line Input# Statement |
Line Input #filenumber, varname
filenumber
Use: Required
Data Type: Integer
Any valid file number.
varname
Use: Required
Data Type: String or Variant
The name of a string or variant variable.
Assigns a single line from a sequential file opened with the For Input method to a string or variant variable.
Data is read into a buffer one character at a time until a line feed or carriage return sequence (either Chr(13) or Chr(13)+Chr(10)) is encountered. When this happens, all characters in the buffer are assigned to varname as a single string, without the carriage return sequence, and the buffer is cleared.
After reading a line, the file pointer advances to the first character after the end of the line or to the end-of-file marker.
Dim intLine As Integer, hFile As Integer Dim strBuffer As String hFile = FreeFile Open "lineinp.txt" For Input As #hFile Do While Not EOF(hFile) intLine = intLine + 1 Line Input #hFile, strBuffer List1.AddItem strBuffer Loop Close #hFile
You use the Line Input statement to read data from unstructured sequential data files. To write data back to this type of file, use the Print # statement.