Ciao Mau
Puoi usare questo codice
Try
Dim countRecord As Integer = -1
' Create an instance of StreamReader to read from a file.
Using sr As StreamReader = New StreamReader("C:\file.txt")
Dim line As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
countRecord += 1
Loop Until line Is Nothing
sr.Close()
MsgBox(countRecord)
End Using
Catch Ex As Exception
' Let the user know what went wrong.
MsgBox("The file could not be read:")
Console.WriteLine(Ex.Message)
End Try
Con l'unica avvertenza che ti legge il file fino alla fine, e quindi se hai delle linee vuote te le conta.
Ciao
alexmed