Delimiters Property


Delimiters Property

Location

TextFieldParser.Delimiters

Syntax

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

or:

     fileParser.Delimiters = setOfDelimiters 


setOfDelimiters (required; String array)

An array of the character or multicharacter values that identify the delimiters used to separate data fields in each input line of a delimited text file being parsed by a TextFieldParser object. End-of-line characters may not be used as field delimiters.

Description

The Delimiters property sets or retrieves the field delimiters used in delimited text-file parsing. Although you can define more than one delimiter, most input files will use a single field delimiter, such as a comma or a tab character.

You can also set the delimiters with the TextFieldParser object's SetDelimiters method.

Usage at a Glance

  • The Delimiters property is only useful with delimited input files, not fixed-width files.

  • Setting the Delimiters property does not alter the current value of the TextFieldType property.

  • An exception is thrown if you attempt to use line-termination characters, zero-length strings, or Nothing as a field delimiter.

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

Example

The following example uses the Delimiters property to indicate the comma character as the field delimiter.

     Dim scanInput As Microsoft.VisualBasic.FileIO.TextFieldParser     ' ...later...     scanInput.TextFieldType = _        Microsoft.VisualBasic.FileIO.FieldType.Delimited scanInput.Delimiters = New String(  ) {","} 

Related Framework Entries

  • Microsoft.VisualBasic.FileIO.TextFieldParser.Delimiters Property

See Also

FieldWidths Property, HasFieldsEnclosedInQuotes Property, ReadFields Method, SetDelimiters Method, SetFieldWidths Method, TextFieldParser Object, TextFieldType Property, TrimWhiteSpace Property




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