Lê uma linha inteira (até o caractere de nova linha, sem incluí-lo) de um arquivo TextStream e retorna a string resultante.
Sintaxe
object.ReadLine( )
Argumentos
Object: Obrigatório. Sempre o nome de um objeto TextStream.
Comentários
O exemplo a seguir ilustra o uso do método ReadLine:
Exemplo 1:
Function ReadFirstLine(filepath)
Const ForReading = 1
Dim fso, theFile, firstLine
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filepath, ForReading)
firstLine = theFile.ReadLine
theFile.Close
ReadFirstLine = firstLine
End Function
' Usage
Dim firstLineContent
firstLineContent = ReadFirstLine("C:\Path\To\Your\File.txt")
Exemplo 2:
Function ReadFileLineByLine(filepath)
Const ForReading = 1
Dim fso, theFile, line
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filepath, ForReading)
Do While Not theFile.AtEndOfStream
line = theFile.ReadLine
Loop
theFile.Close
End Function
' Usage
ReadFileLineByLine "C:\Path\To\Your\File.txt"