TextFieldParser クラス
アセンブリ: Microsoft.VisualBasic (microsoft.visualbasic.dll 内)
構文
Public Class TextFieldParser Implements IDisposable
public class TextFieldParser : IDisposable
public ref class TextFieldParser : IDisposable
public class TextFieldParser implements IDisposable
public class TextFieldParser implements IDisposable
詳細については、Visual Basic のトピック「TextFieldParser オブジェクト」を参照してください。
TextFieldParser オブジェクトは、構造化されたテキスト ファイルを解析するためのメソッドおよびプロパティを提供します。テキスト ファイルを TextFieldParser で解析することによってテキスト ファイルが反復処理されます。また、ReadFields を使用することによって、テキストからフィールドを抽出 (つまり、文字列を分割) できます。
TextFieldParser では、区切り形式と固定幅の 2 種類のファイルを解析できます。このオブジェクトが公開するプロパティには、区切り形式のファイルでしか意味を持たないもの (Delimiters、HasFieldsEnclosedInQuotes など) や、固定幅のファイルでしか意味を持たないもの (FieldWidths プロパティ) があります。
Microsoft.VisualBasic.FileIO.TextFieldParser オブジェクトを使ったタスクの例を次の表に示します。
この例では、タブ区切りのテキスト ファイル Bigfile を解析します。
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser _ ("c:\logs\bigfile") MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited MyReader.Delimiters = New String() {vbTab} Dim currentRow As String() 'Loop through all of the fields in the file. 'If any lines are corrupt, report an error and continue parsing. While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() ' Include code here to handle the row. Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Line " & ex.Message & _ " is invalid. Skipping") End Try End While End Using
Microsoft.VisualBasic.FileIO.TextFieldParser
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
TextFieldParser メンバ
Microsoft.VisualBasic.FileIO 名前空間
TextFieldParser クラス
その他の技術情報
TextFieldParser オブジェクト
TextFieldParser オブジェクトのメンバ
TextFieldParser.CommentTokens プロパティ
TextFieldParser.Delimiters プロパティ
TextFieldParser.EndOfData プロパティ
TextFieldParser.ErrorLine プロパティ
TextFieldParser.ErrorLineNumber プロパティ
TextFieldParser.FieldWidths プロパティ
TextFieldParser.HasFieldsEnclosedInQuotes プロパティ
TextFieldParser.LineNumber プロパティ
TextFieldParser.TextFieldType プロパティ
TextFieldParser.TrimWhiteSpace プロパティ
TextFieldParser.Close メソッド
TextFieldParser.PeekChars メソッド
TextFieldParser.ReadFields メソッド
TextFieldParser.ReadLine メソッド
TextFieldParser.ReadToEnd メソッド
TextFieldParser.SetDelimiters メソッド
TextFieldParser.SetFieldWidths メソッド
My.Computer.FileSystem.OpenTextFieldParser メソッド
TextFieldParser オブジェクトによるテキスト ファイルの解析
例外のトラブルシューティング : Microsoft.VisualBasic.FileIO.TextFieldParser.MalformedLineException
- TextFieldParser クラスのページへのリンク