TextFieldParser.SetFieldWidths(Int32[]) メソッド

定義

リーダーの区切り記号を指定した値に設定します。

public:
 void SetFieldWidths(... cli::array <int> ^ fieldWidths);
public void SetFieldWidths(params int[] fieldWidths);
member this.SetFieldWidths : int[] -> unit
Public Sub SetFieldWidths (ParamArray fieldWidths As Integer())

パラメーター

fieldWidths
Int32[]

Integerの配列。

次の使用例は、テキスト フィールド パーサーを開き、フィールドの幅を 5として定義します。

Using FileReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\logs\test.log")

    FileReader.SetFieldWidths(5)
End Using

C:\logs\test.logパスを、解析するファイルのパスと名前に置き換えます。

次の例では、テキスト フィールド パーサーを開き、フィールドの幅を 510、変数として定義します。

Using MyReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\logs\test.log")

    MyReader.SetFieldWidths(5, 10, -1)
End Using

C:\logs\test.logパスを、解析するファイルのパスと名前に置き換えます。

注釈

Delimiters プロパティの既存の内容は、この設定時にクリアされます。

このメソッドは、配列を作成せずに区切り記号を設定する方法を提供します。

次の表に、 SetFieldWidths メソッドに関連するタスクの例を示します。

ターゲット 参照先
テキスト ファイルを解析します。 TextFieldParser オブジェクトを使用したテキスト ファイルの解析

適用対象

こちらもご覧ください