Reads data from an open sequential file and assigns the data to variables.
FileNumber does not exist.
File mode is invalid.
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.
The Input function is provided for backward compatibility and may have an impact on performance. For non-legacy applications, the My.Computer.FileSystem object provides better performance. For more information, see File Access with Visual Basic.
Data read with Input is usually written to a file with Write. Use this function only with files opened in Input or Binary mode.
When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file named Form1.vb may not be a Visual Basic source file.
When read, standard string or numeric data is assigned to variables without modification. The following table illustrates how other input data is treated.
Value assigned to variable
Delimiting comma or blank line
#TRUE# or #FALSE#
True or False
The date and/or time represented by the expression
errornumber (variable is an object tagged as an error)
If you reach the end of the file while you are inputting a data item, the input is terminated and an error occurs.
The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, since the comma is treated as a variable separator rather than a decimal point.
Reading from a file with the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess Enumeration.
This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file with a few lines of data written to it using the Write function, each line containing a string in quotations and a number separated by a comma, for example: ("Hello", 234).
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)