Name
Input Procedure
Class
Microsoft.VisualBasic.FileSystem
Syntax
LineInput(filenumber,value)-
filenumber Use: Required
Data Type: Integer
Any valid file number
-
value Use: Required
Data Type: Any
Data to read from file
Description
Reads delimited data from a file into variables. This statement is used to read files that were created using the Write procedure, in which case the items are comma delimited with quotation marks around strings.
Rules at a Glance
Data read by
Inputhas usually been written using the Write procedure.Use this statement with files that have been opened in Input or Binary mode only.
If
valueis numeric and theInputprocedure encounters non-numeric data, an InvalidCastException exception occurs.The
Inputprocedure strips off the quotation marks that it finds around strings.After the
Inputprocedure readsvalue, it advances the file pointer to the next unread variable or, if the file contains no additional delimited data, to the end of the file.If the end of the file is reached during the operation of the
Inputprocedure, an error is generated.The
Inputprocedure assigns string or numeric data tovaluewithout modification. However, other types of data can be modified as shown in the following table:Data
Value assigned to variable
Delimiting comma or blank line
“” (empty string)
#TRUE#or#FALSE#TrueorFalse#yyyy-mm-dd hh:mm:ss#Date and/or time
Note that
#TRUE#and#FALSE#are case sensitive.
Example
If the file c:\data.txt contains the following ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access