LocationTextFieldParser.SetFieldWidths SyntaxDim fileParser As FileIO.TextFieldParser ' ...later... fileParser.SetFieldWidths(setOfWidths)
DescriptionThe SetFieldWidths method sets the number of characters used for each field in fixed-width text file parsing. This method also sets the TextFieldParser object's TextFieldType property to Microsoft.VisualBasic.FileIO.FieldType.FixedWidth. The first field begins with the first character on each record line, and subsequent fields immediately follow the fields before. You can indicate that the last field is of variable length (that is, it includes all characters until the end of the line) by setting the last field width to -1. You can use the TextFieldParser object's FieldWidths property to set the field widths as well, but that property does not alter the TextFieldType property. Usage at a Glance
ExampleThe following example uses the SetFieldWidths method to indicate that each line in the input file contains three fields: a 3-character field, a 30-character field, and a 5-character field. Dim scanInput As Microsoft.VisualBasic.FileIO.TextFieldParser ' ...later... scanInput.SetFieldWidths(New Integer( ) {3, 30, 5}) Related Framework Entries
See AlsoCommentTokens Property, Delimiters Property, FieldWidths Property, ReadFields Method, SetDelimiters Method, TextFieldParser Object, TextFieldType Property |