TextFieldParser.LineNumber 속성

정의

현재 줄 번호를 반환하거나 스트림에서 더 이상 문자를 사용할 수 없으면 -1을 반환합니다.

public:
 property long LineNumber { long get(); };
public long LineNumber { get; }
member this.LineNumber : int64
Public ReadOnly Property LineNumber As Long

속성 값

현재 줄 번호입니다.

예제

이 예제에서는 텍스트 파일에서 "Jones"라는 이름을 검색하고 어떤 줄이 발생하는지 보고합니다.

Using FileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\ParserText.txt")
    FileReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
    FileReader.Delimiters = New String() {","}
    Dim currentRow As String()
    While Not FileReader.EndOfData
        Try
            currentRow = FileReader.ReadFields()
            Dim currentField As String
            For Each currentField In currentRow
                If currentField = "Jones" Then
                    MsgBox("The name Jones occurs on line " & 
                    FileReader.LineNumber)
                End If
            Next
        Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
            MsgBox("Line " & ex.Message & 
           "is not valid and will be skipped.")
        End Try
    End While
End Using

설명

이 메서드는 고급 멤버; 클릭 하지 않으면 IntelliSense에 표시 되지 않습니다 합니다 모든 탭 합니다.

줄 번호를 결정할 때 빈 줄과 주석은 무시되지 않습니다.

적용 대상

추가 정보