Редагувати

Поділитися через


FileSystem.Input Method

Definition

Reads data from an open sequential file and assigns the data to variables.

Overloads

Input(Int32, Object)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int64)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int32)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Int16)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Double)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Boolean)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, DateTime)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Char)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Byte)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Single)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Decimal)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, String)

Reads data from an open sequential file and assigns the data to variables.

Input(Int32, Object)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, System::Object ^ % Value);
public static void Input (int FileNumber, ref object Value);
static member Input : int * obj -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Object)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Object

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Int64)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, long % Value);
public static void Input (int FileNumber, ref long Value);
static member Input : int * int64 -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Long)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int64

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Int32)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, int % Value);
public static void Input (int FileNumber, ref int Value);
static member Input : int * int -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Integer)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int32

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

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 instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Int16)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, short % Value);
public static void Input (int FileNumber, ref short Value);
static member Input : int * int16 -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Short)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Int16

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Double)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, double % Value);
public static void Input (int FileNumber, ref double Value);
static member Input : int * double -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Double)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Double

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Boolean)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, bool % Value);
public static void Input (int FileNumber, ref bool Value);
static member Input : int * bool -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Boolean)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Boolean

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has some 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, DateTime)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, DateTime % Value);
public static void Input (int FileNumber, ref DateTime Value);
static member Input : int * DateTime -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As DateTime)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
DateTime

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Char)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, char % Value);
public static void Input (int FileNumber, ref char Value);
static member Input : int * char -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Char)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Char

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Byte)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, System::Byte % Value);
public static void Input (int FileNumber, ref byte Value);
static member Input : int * byte -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Byte)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Byte

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has some 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Single)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, float % Value);
public static void Input (int FileNumber, ref float Value);
static member Input : int * single -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Single)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Single

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, Decimal)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, System::Decimal % Value);
public static void Input (int FileNumber, ref decimal Value);
static member Input : int * decimal -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As Decimal)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
Decimal

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to

Input(Int32, String)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Reads data from an open sequential file and assigns the data to variables.

public:
 static void Input(int FileNumber, System::String ^ % Value);
public static void Input (int FileNumber, ref string Value);
static member Input : int * string -> unit
Public Sub Input (FileNumber As Integer, ByRef Value As String)

Parameters

FileNumber
Int32

Required. Any valid file number.

Value
String

Required. Variable that is assigned the values read from the file - cannot be an array or object variable.

Exceptions

File mode is invalid.

Examples

This example uses the Input function to read data from a file into two variables. This example assumes that TestFile is a file that has several 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).

FileOpen(1, "TESTFILE", OpenMode.Output)
Write(1, "hello")
Write(1, 14)
FileClose(1)
Dim s As String = "teststring"
Dim i As Integer
FileOpen(1, "TESTFILE", OpenMode.Input)
Input(1, s)
MsgBox(s)
Input(1, i)
MsgBox(i)
FileClose(1)

Remarks

The Input function is provided for backward compatibility and may affect 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 by using Write. Use this function only with files opened in Input or Binary mode.

Important

When reading from files, do not make decisions about the contents of the file based on the file name extension. For example, a file that is named Form1.vb may not be a Visual Basic 2005 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.

Data Value assigned to variable
Delimiting comma or blank line Empty
#NULL# DBNull
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss# The date and/or time represented by the expression
#ERROR errornumber# 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 stopped and an error occurs.

Note

The Input function is not localized. For example, in the German version, if you input 3,14159, it returns only 3, because the comma is treated as a variable separator instead of as a decimal point.

Important

Reading from a file by using the Input function requires Read access from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess.

See also

Applies to