Following is my FileRead method in my TextFile class.For some reason, some files end up with an extra three characters at the beginning of the datastream. The characters are not in the filre, and Access 2007 / VBA does not add the characters to all files it reads.
Did I code something incorrectly, or must I leave my hack in the method?
Did I code something incorrectly, or must I leave my hack in the method?
Code:
Public Function FileRead() As Boolean
On Error GoTo Err_FileRead
Dim lnFileSize As Long
'Make sure the read buffer is empty to start with
strFileReadBuffer = ""
'Check file size
lnFileSize = LOF(FileNumber)
'Read the entire file into memory
strFileReadBuffer = Input(lnFileSize, FileNumber)
'Hack to strip off some bazar leading characters from files, needed only sometimes... (shrug)
If Mid(strFileReadBuffer, 1, 3) = "" Then
strFileReadBuffer = Mid(strFileReadBuffer, 4)
End If
'Good return code
FileRead = True
Exit_FileRead:
Exit Function
Err_FileRead:
Call errorhandler_MsgBox("Class: clsObjTxtFileUtils, Subroutine: FileRead()")
FileRead = False
Resume Exit_FileRead
End Function