LocationTextFieldParser.PeekChars SyntaxDim fileParser As FileIO.TextFieldParser ' ...later... Dim result As String = fileParser.PeekChars(peekLength)
DescriptionThe PeekChars method returns the specified number of characters from the current position in the input file, but it does not alter the current position. Blank lines are ignored when using this method. Usage at a Glance
ExampleThis code opens a tab-delimited file for scanning but stops early if it detects an artificial end-of-file marker. Dim oneLine( ) As String Dim inputFile As FileIO.TextFieldParser = _ My.Computer.FileSystem.OpenTextFieldParser( _ "c:\temp\data.txt", vbTab) Do While Not inputFile.EndOfData ' ----- Check for the EOF marker. If (inputFile.PeekChars(3) = "EOF") Then Exit Do ' ----- OK to process this line. oneLine = inputFile.ReadFields( ) ' ----- Process data here... Loop inputFile.Close( ) Related Framework Entries
See AlsoEndOfData Property, LineNumber Property, ReadFields Method, ReadLine Method, ReadToEnd Method, TextFieldParser Object |