What I'm trying to do is read a image file in (which works), and then rewrite it.
The problem is in the rewriting it.
I can't just copy it because I'll be doing some bit manipulation before it's written back out.
Tried various stuff and it didn't work.
Sub test
Dim binfile As Variant
binfile = readBinFile(Text1)
WriteBinFile "c:\msat\coin3.ico", binfile
exit sub
Function readBinFile(ByRef bfilename As String) As Variant
Dim fl As Long
Dim FileNum As Long
Dim binbyte() As Byte
Dim binfilestr As String
On Error GoTo errHandler
FileNum = FreeFile
'bfilename = Text1
Open bfilename For Binary Access Read As #FileNum
fl = FileLen(bfilename)
ReDim binbyte(fl)
Get #FileNum, , binbyte
Close #FileNum
readBinFile = binbyte
Exit Function
errHandler:
End Function
Function WriteBinFile(ByRef bfilename As String, ByRef binbyte As Variant) As Variant
Dim fl As Long
Dim FileNum As Long
'Dim binbyte() As Byte
Dim binfilestr As String
Dim i As Long
On Error GoTo errHandler
FileNum = FreeFile
Open bfilename For Binary As #FileNum
For i = 0 To UBound(binbyte) - 1
binfilestr = binfilestr & binbyte(i)
Next i
Put #FileNum, , binfilestr
Close #FileNum
'readBinFile = binbyte
Exit Function
errHandler:
End Function
nordycki@hotmail.com
The problem is in the rewriting it.
I can't just copy it because I'll be doing some bit manipulation before it's written back out.
Tried various stuff and it didn't work.
Sub test
Dim binfile As Variant
binfile = readBinFile(Text1)
WriteBinFile "c:\msat\coin3.ico", binfile
exit sub
Function readBinFile(ByRef bfilename As String) As Variant
Dim fl As Long
Dim FileNum As Long
Dim binbyte() As Byte
Dim binfilestr As String
On Error GoTo errHandler
FileNum = FreeFile
'bfilename = Text1
Open bfilename For Binary Access Read As #FileNum
fl = FileLen(bfilename)
ReDim binbyte(fl)
Get #FileNum, , binbyte
Close #FileNum
readBinFile = binbyte
Exit Function
errHandler:
End Function
Function WriteBinFile(ByRef bfilename As String, ByRef binbyte As Variant) As Variant
Dim fl As Long
Dim FileNum As Long
'Dim binbyte() As Byte
Dim binfilestr As String
Dim i As Long
On Error GoTo errHandler
FileNum = FreeFile
Open bfilename For Binary As #FileNum
For i = 0 To UBound(binbyte) - 1
binfilestr = binfilestr & binbyte(i)
Next i
Put #FileNum, , binfilestr
Close #FileNum
'readBinFile = binbyte
Exit Function
errHandler:
End Function
nordycki@hotmail.com