M
Mike Iacovou
Hi all,
I'm trying to read in a binary file... I found a VB6 script that 'should'
work, but get an error using it in Access 2003. I get a 458 error 'Variable
uses an automation type not supported in visual basic' at the 'Get #iFileNum,
, vThisBlock' line... The file path is correct...
I am happy to abandon this procedure for any that will read in a file
binary... the file is infact a DLL that is required by some db functions...
it will be extracted and saved to hard drive if it is not found - thus
ensuring the system will run... thus a binary load / save is required...
any guidance appreciated...
Function FileReadBinary(sFileName As String) As Variant
Dim iFileNum As Integer, lFileLen As Long
Dim vThisBlock As Variant, lThisBlock As Long, vFileData As Variant
'On Error GoTo ErrFailed
If Len(Dir$(sFileName)) > 0 And Len(sFileName) > 0 Then
iFileNum = FreeFile
Open sFileName For Binary Access Read As #iFileNum
lFileLen = LOF(iFileNum)
Do
lThisBlock = lThisBlock + 1
Get #iFileNum, , vThisBlock
If IsEmpty(vThisBlock) = False Then
If lThisBlock = 1 Then
ReDim vFileData(1 To 1)
Else
ReDim Preserve vFileData(1 To lThisBlock)
End If
vFileData(lThisBlock) = vThisBlock
End If
Loop While EOF(iFileNum) = False
Close iFileNum
FileReadBinary = vFileData
End If
Exit Function
ErrFailed:
Close iFileNum
MsgBox Err.Description
End Function
I'm trying to read in a binary file... I found a VB6 script that 'should'
work, but get an error using it in Access 2003. I get a 458 error 'Variable
uses an automation type not supported in visual basic' at the 'Get #iFileNum,
, vThisBlock' line... The file path is correct...
I am happy to abandon this procedure for any that will read in a file
binary... the file is infact a DLL that is required by some db functions...
it will be extracted and saved to hard drive if it is not found - thus
ensuring the system will run... thus a binary load / save is required...
any guidance appreciated...
Function FileReadBinary(sFileName As String) As Variant
Dim iFileNum As Integer, lFileLen As Long
Dim vThisBlock As Variant, lThisBlock As Long, vFileData As Variant
'On Error GoTo ErrFailed
If Len(Dir$(sFileName)) > 0 And Len(sFileName) > 0 Then
iFileNum = FreeFile
Open sFileName For Binary Access Read As #iFileNum
lFileLen = LOF(iFileNum)
Do
lThisBlock = lThisBlock + 1
Get #iFileNum, , vThisBlock
If IsEmpty(vThisBlock) = False Then
If lThisBlock = 1 Then
ReDim vFileData(1 To 1)
Else
ReDim Preserve vFileData(1 To lThisBlock)
End If
vFileData(lThisBlock) = vThisBlock
End If
Loop While EOF(iFileNum) = False
Close iFileNum
FileReadBinary = vFileData
End If
Exit Function
ErrFailed:
Close iFileNum
MsgBox Err.Description
End Function