Reads a single line from an open sequential file and assigns it to a String variable.
Public Function LineInput(ByVal FileNumber As Integer) As String
- Required. Any valid file number.
|Exception type||Error number||Condition|
|EndOfStreamException||62||End of file reached.|
|IOException||52||FileNumber does not exist.|
Data read with LineInput is usually written to a file with Print.
Security Note When reading from files, do not make decisions about the contents of a file based on the file name extension. For example, a file named Form1.vb may not be a Visual Basic .NET source file.
The LineInput function reads from a file one character at a time until it encounters a carriage return (Chr(13)) or carriage return–linefeed (Chr(13) + Chr(10)) sequence. Carriage return–linefeed sequences are skipped rather than appended to the character string.
Security Note Reading from a file with the LineInput function requires Read assess from the FileIOPermissionAccess enumeration. For more information, see FileIOPermissionAccess Enumeration.
This example uses the LineInput function 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.
Dim TextLine As String FileOpen(1, "TESTFILE", OpenMode.Input) ' Open file. While Not EOF(1) ' Loop until end of file. TextLine = LineInput(1) ' Read line into variable. Debug.WriteLine(TextLine) ' Print to the console. End While FileClose(1) ' Close file.
Smart Device Developer Notes
This function is not supported.
Assembly: Microsoft Visual Basic .NET Runtime (in Microsoft.VisualBasic.dll)