Reads file in binary mode as blocks
Starts reading from start in sequential mode, but with control over how many bytes every line has will enable you to reach certain point of file needed.
One of my attempts to read large files
Function ReadBinaryBuffer(Filename, Optional LineBuffer = 6000, Optional FromLine = 10)
' Reads certain position of file
Dim OneChunk as string
iFile = FreeFile()
Open Filename For Binary Access Read As #iFile
If LineBuffer = 0 Then LineBuffer = LOF(iFile)
OneChunk = String(LineBuffer, " ")
Rett = ""
Do Until Eof(iFile)
LineX1 = LineX1 + 1
Get #iFile,,OneChunk
If LineX1 >= FromLine Then
Rett = OneChunk
Exit do
End If
Doevents
Loop
Close #iFile
ReadBinaryBuffer = Rett
End Function
' Reads certain position of file
Dim OneChunk as string
iFile = FreeFile()
Open Filename For Binary Access Read As #iFile
If LineBuffer = 0 Then LineBuffer = LOF(iFile)
OneChunk = String(LineBuffer, " ")
Rett = ""
Do Until Eof(iFile)
LineX1 = LineX1 + 1
Get #iFile,,OneChunk
If LineX1 >= FromLine Then
Rett = OneChunk
Exit do
End If
Doevents
Loop
Close #iFile
ReadBinaryBuffer = Rett
End Function
Filename, Optional LineBuffer = 6000, Optional FromLine = 10
Views 173
Downloads 66
CodeID
DB ID