投稿/コメントを表示します。

「Do Until txt.AtEndOfStream」で読み込むとテキストファイルの中身全て(広瀬川.....萩原朔太郎)が読み込まれますが、「Do Until txt.AtEndOfLine」にすると「広瀬川.....もとまらず。」と最後の1行が読み込まれませんが、どういった違いなのでしょうか?
Sub ReadText2()
    Dim fs As Scripting.FileSystemObject
    Dim txt As TextStream
    Dim path As String
    Dim stEachline As String
    
    path = ThisWorkbook.path & "\fsosample\textfile1.txt"
    Set fs = New Scripting.FileSystemObject
    
    Set txt = fs.OpenTextFile(filename:=path, IOMode:=ForReading, create:=True, _
        Format:=TristateUseDefault)
    
    Do Until txt.AtEndOfStream
        stEachline = txt.ReadLine
        Debug.Print stEachline
    Loop

    txt.Close
    Set txt = Nothing
    Set fs = Nothing
End Sub

2015/11/25 01:19