If You write to a file in Random mode, You can use Seek
statement to find last record.
For example:
Type Record ' Define user-defined type.
ID As Integer
Name As String * 20
End Type
Dim MyRecord As Record, MaxSize, RecordNumber ' Declare
variables.
' Open file in random-file mode.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
MaxSize = LOF(1) \ Len(MyRecord) ' Get number of records
in file.
' The loop reads all records starting from the last.
For RecordNumber = MaxSize To MaxSize - 1
Seek #1, RecordNumber ' Set position.
Get #1, , MyRecord ' Read last record.
Next RecordNumber
Close #1 ' Close file.
But, if You use other mode to read data in text file, I
don't know best way to do this. Try it:
Function ReadLastLine(fName As String) As String
Dim fNum As Long
Dim strtemp As String
fNum = FreeFile()
Open fName For Input As #fNum
Do While Not EOF(fNum) 'ignore all line, not last
Line Input #fNum, strtemp
Loop
Close #fNum
ReadLastLine = strtemp
End Function