LocationTextFieldParser.ReadFields SyntaxDim fileParser As FileIO.TextFieldParser ' ...later... Dim result As String( ) = fileParser.ReadFields( ) DescriptionThe ReadFields method is the main processing method of the TextFieldParser object. It reads all delimited or fixed-width fields in the current record of the input file and returns those fields as a string array. The fields returned from a delimited input file may be altered in content through the HasFieldsEnclosedInQuotes and TrimWhiteSpace properties. Blank lines and comment lines are always ignored. After reading the record, the current file position advances to the start of the next record. Usage at a GlanceAn exception is thrown if the parser is unable to extract the delimited or fixed-width fields currently configured through the TextFieldParser object. The ErrorLine and ErrorLineNumber properties will provide details on the errant record. ExampleThis code processes a tab-delimited file using the ReadFields method. Dim oneLine( ) As String Dim inputFile As FileIO.TextFieldParser = _ My.Computer.FileSystem.OpenTextFieldParser( _ "c:\temp\data.txt", vbTab) Do While Not inputFile.EndOfData oneLine = inputFile.ReadFields( ) ' ----- Process data here... Loop inputFile.Close( ) Related Framework Entries
See AlsoClose Method, CommentTokens Property, Delimiters Property, EndOfData Property, ErrorLine Property, ErrorLineNumber Property, FieldWidths Property, HasFieldsEnclosedInQuotes Property, LineNumber Property, PeekChars Method, ReadLine Method, ReadToEnd Method, SetDelimiters Method, SetFieldWidths Method, TextFieldParser Object, TextFieldType Property, TrimWhiteSpace Property |