Sub Sample1()
Dim buf As String
Const Target As String = "C:\Count.log"
Open Target For Input As #1
Do Until EOF(1)
Line Input #1, buf
Loop
Close #1
MsgBox "最終行のデータは、" & buf
End Sub
Sub Sample2()
Dim buf As String, FSO As Object
Const Target As String = "C:\Count.log"
Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.OpenTextFile(Target, 1)
buf = .ReadAll
.Close
End With
Debug.Print buf
End Sub
Sub Sample3()
Dim buf As String, LastRow As Long, FSO As Object
Const Target As String = "C:\Count.log"
Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.OpenTextFile(Target, 1)
buf = .ReadAll
.Close
End With
Set FSO = Nothing
LastRow = UBound(Split(buf, vbCrLf)) - 1
MsgBox Split(buf, vbCrLf)(LastRow)
End Sub
Sub Sample4()
Dim buf As String, LastRow As Long, FSO As Object
Const Target As String = "C:\Count.log"
Set FSO = CreateObject("Scripting.FileSystemObject")
With FSO.OpenTextFile(Target, 1)
buf = .ReadAll
.Close
End With
Set FSO = Nothing
LastRow = UBound(Split(buf, vbCrLf)) - 1
buf = Split(buf, vbCrLf)(LastRow)
MsgBox Split(buf, " ")(1)
End Sub