Legge un'intera riga (fino al carattere di nuova riga escluso) da un file TextStream e restituisce la stringa risultante.
Sintassi
object.ReadLine( )
Argomenti
Object: obbligatorio. Sempre il nome di un oggetto TextStream.
Note
Nell'esempio seguente viene illustrato l'uso del metodo ReadLine.
Esempio 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")
Esempio 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"