LocationTextFieldParser.ReadLine SyntaxDim fileParser As FileIO.TextFieldParser ' ...later... Dim result As String = fileParser.ReadLine( ) DescriptionThe ReadLine method reads and returns the current line from a file being parsed with the TextFieldParser object. The returned line is not parsed into distinct fields. If the file position is already at the end of the file, this method returns an empty string. This method advances the current file position to the start of the next line. Usage at a GlanceYou must close the TextFieldParser object when finished with it. Use the object's Close method or create the object instance with the Using keyword. See the TextFieldParser Object entry in this chapter for an example. ExampleThis code opens a tab-delimited file for scanning but performs a different type of processing on lines marked by a special preamble. Dim oneLine As String Dim fieldSet( ) As String Dim inputFile As FileIO.TextFieldParser = _ My.Computer.FileSystem.OpenTextFieldParser( _ "c:\temp\data.txt", vbTab) Do While Not inputFile.EndOfData ' ----- Check for the special processing flag. If (inputFile.PeekChars(5) = "SPEC:") Then ' ----- Do special processing of this line. oneLine = inputFile.ReadLine( ) ' ----- Process data here... Else ' ----- OK to process this line normally. fieldSet = inputFile.ReadFields( ) ' ----- Process data here... End If Loop inputFile.Close( ) Related Framework Entries
See AlsoClose Method, CommentTokens Property, EndOfData Property, LineNumber Property, PeekChars Method, ReadFields Method, ReadToEnd Method, TextFieldParser Object |