TextFieldParser.TextFieldType Property

 

Indicates whether the file to be parsed is delimited or fixed-width.

Namespace:   Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public FieldType TextFieldType { get; set; }

Property Value

Type: Microsoft.VisualBasic.FileIO.FieldType

A TextFieldType value that indicates whether the file to be parsed is delimited or fixed-width.

The default value of this property is delimited.

The following table lists examples of tasks involving the TextFieldType property.

To

See

Read from a delimited text file

How to: Read From Comma-Delimited Text Files in Visual Basic

Read from a fixed-width text file

How to: Read From Fixed-width Text Files in Visual Basic

Read from a text file with multiple formats

How to: Read From Text Files with Multiple Formats in Visual Basic

This example creates a TextFieldParser, FileReader, and specifies that it is delimited.

Using FileReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\ParserText.txt")

    FileReader.TextFieldType = 
        Microsoft.VisualBasic.FileIO.FieldType.Delimited
    FileReader.SetDelimiters(",")
End Using

This example creates a TextFieldParser, FileReader, and specifies that it is fixed-width.

Using FileReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\ParserText.txt")

    FileReader.TextFieldType = 
        Microsoft.VisualBasic.FileIO.FieldType.FixedWidth
    FileReader.FieldWidths = New Integer() {5, 10, 11, -1}
End Using

.NET Framework
Available since 2.0
Return to top
Show: