Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Created March 18, 2011 16:02
Show Gist options
  • Save Vaysman/876329 to your computer and use it in GitHub Desktop.
Save Vaysman/876329 to your computer and use it in GitHub Desktop.
read binary file on vb 6
Dim iFile As Integer
Dim lByteLen As Long
Dim bytData As Byte
Dim bytArray() As Byte
Dim sHex As String
'get an available file ID
iFile = FreeFile
'open the file for access
Open "C:\MyFile.ext" For Binary As iFile
'get current len of file
lByteLen = LOF(iFile)
If lByteLen >= 11 Then
Get iFile, 11, bytData
sHex = Hex(bytData)
'write over a byte
bytData = Asc("Z")
Put iFile, 9, bytData
'grab entire file contents
Redim bytArray(1 To lByteLen)
Get iFile, 1, bytArray
End If
'must close file when done
Close iFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment