TextFieldParser.LineNumber Propriedade
Definição
Retorna o número de linha atual ou -1 se não houver mais nenhum caractere disponível no fluxo.Returns the current line number, or returns -1 if no more characters are available in the stream.
public:
property long LineNumber { long get(); };
public long LineNumber { get; }
member this.LineNumber : int64
Public ReadOnly Property LineNumber As Long
Valor da propriedade
O número de linha atual.The current line number.
Exemplos
Este exemplo pesquisa o nome "Jones" no arquivo de texto e relata em quais linhas ele ocorre.This example searches for the name "Jones" in the text file and reports what line(s) it occurs on.
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
Comentários
Este é um membro avançado; Ele não aparecerá no IntelliSense, a menos que você clique na guia tudo .This is an advanced member; it does not show in IntelliSense unless you click the All tab.
As linhas em branco e os comentários não são ignorados ao determinar o número da linha.Blank lines and comments are not ignored when determining the line number.