LineInput Function


LineInput Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

     Dim result As String = LineInput(fileNumber) 


filenumber (required; Integer)

Any valid file number of a file opened with FileOpen

Description

The LineInput function returns a single line of text from a file opened in Input mode. Single lines are delimited by carriage returns (vbCr) or carriage return/line-feed pairs (vbCrLf). The line-delimiting characters are not included in the returned string.

Usage at a Glance

  • After reading a line, the file pointer advances to the first character after the end of the line, or to the end of file if there are no more lines.

  • Data read with the LineInput function is normally written to the source file with the Print and PrintLine procedures.

Example

The following code reads all of the lines in a text file and sends them to the Output window:

     Dim fileID As Integer = FreeFile(  )     FileOpen(fileID, "c:\data.txt", OpenMode.Input, OpenAccess.Read)     Do While Not EOF(fileID)        Console.WriteLine(LineInput(fileID))     Loop     FileClose(fileID) 

Version Differences

  • The LineInput function differs syntactically from the LineInput statement used in VB 6.

  • In Visual Basic 2005, the My.Computer.FileSystem object provides more robust access to file-management features.

See Also

Print, PrintLine Procedures




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net