TextFieldParser.SetFieldWidths メソッド
更新 : 2008 年 7 月
リーダー用のデリミタを指定の値に設定します。
' Usage
TextFieldParserObject.SetFieldWidths(fieldWidths)
' Declaration
Public Sub SetFieldWidths( _
ByVal fieldWidths As Integer() _
)
パラメータ
- fieldWidths
Integer の配列。
例外
例外がスローされる可能性のある状態を次に示します。
- デリミタが整数 (ArgumentException) ではありません。
解説
Delimiters プロパティの既存の内容は、設定時にクリアされます。
このメソッドを使うと、配列を作成せずにデリミタを設定できます。
処理手順
SetFieldWidths メソッドに関連するタスクの例を次の表に示します。
タスク |
参照項目 |
---|---|
テキスト ファイルを解析します。 |
使用例
このコード例は、テキスト フィールド パーサーを開き、フィールドの幅を 5 に定義します。
Using FileReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\logs\test.log")
FileReader.SetFieldWidths(5)
End Using
パス C:\logs\test.log を、解析するファイルのパスと名前に置き換えてください。
このコード例は、テキスト フィールド パーサーを開き、フィールドの幅を 5、10、および変数に定義します。
Using MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\logs\test.log")
MyReader.SetFieldWidths(5, 10, -1)
End Using
パス C:\logs\test.log を、解析するファイルのパスと名前に置き換えてください。
必要条件
名前空間 : Microsoft.VisualBasic.FileIO
クラス : TextFieldParser
アセンブリ : Microsoft Visual Basic ランタイム (Microsoft.VisualBasic.dll 内)
アクセス許可
アクセス許可は不要です。
参照
概念
TextFieldParser オブジェクトによるテキスト ファイルの解析
参照
TextFieldParser.SetDelimiters メソッド
変更履歴
日付 |
履歴 |
理由 |
---|---|---|
2008 年 7 月 |
最初の文を変更 |
カスタマ フィードバック |