
Searching ASCII in a binary file ?
Quote:
> I have a binary file called xyz.bin
> I want to get some text included in this file ("blahblah for"
example)
> I know it is stored betwen $0100 and $0110 in the file (for example)
> Can someone help me acheiving this ?
Frederic,
You might want to try this. I'm sure there are more elegant solutions,
but this works:
--- start of code ---
Dim sArg As String, sFile As String
Dim nHndl As Integer
Dim sBuffer As String
Dim nStart as Long, nLength as Long
sArg = "blahblah"
sFile = "c:\xyz.bin"
nStart = &H100
nLength = (&H110 - nStart) + 1
nHndl = FreeFile
Open sFile For Binary Access Read As #nHndl
' position the file pointer
Seek #nHndl, nStart
' read in the string
sBuffer = Input(nLength, #nHndl)
If InStr(sBuffer, sArg) > 0 Then
' you have found your target string
End If
--- end of code ---
Hope this helps,
Larry Fee
Systems Division, Corporate and Strategic Programs
Ministry of Health, Victoria BC Canada
Phone: (250) 952-1413 Fax..: (250) 952-2308