CommentTokens Property


CommentTokens Property

Location

TextFieldParser.CommentTokens

Syntax

         Dim fileParser As FileIO.TextFieldParser         ' ...later...     Dim result As String(  ) = fileParser.CommentTokens 

or:

     fileParser.CommentTokens = setOfTokens 


setOfTokens (required; String array)

An array of the character or multicharacter values that, when appearing at the start of a line in the input file being parsed by a TextFieldParser object, indicate that the line should be considered as a comment. Any array elements with zero-length strings are ignored.

Description

The CommentTokens property sets or retrieves the comment tokens used with a TextFieldParser object. Each comment token is a string of one or more characters. As each line of the input file is read by the parser, a comparison is done between each token and the first few characters of the input line. If there is a token match, the whole line is considered to be a comment line, and no fields are extracted from the line.

Usage at a Glance

  • The CommentTokens property is valid with either fixed-width or delimited input files.

  • You 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.

  • Tokens assigned to the CommentTokens property may not include whitespace characters.

Example

The following example sets two comment tokens for the input file: "//" and "REM."

         Dim scanInput As Microsoft.VisualBasic.FileIO.TextFieldParser         ' ...later...     scanInput.CommentTokens = New String(  ) {"//", "REM"} 

Related Framework Entries

  • Microsoft.VisualBasic.FileIO.TextFieldParser.CommentTokens Property

See Also

Delimiters Property, FieldWidths Property, PeekChars Method, TextFieldParser Object




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