As an example, opening a Jpeg, results in FFD8 FFE1 (which is correct - that's the magic number for a jpeg) for both methods
Dim strFullName As String
Dim intFNum As Integer
Dim lngReadPos As Long, x As Long
Dim BytGetHeader As Byte
Dim avarBuffer As Variant
Dim lngGetHeader2 As Long
Dim hxValue As String
'user prompted to pick file
strFullName = fnstrFilePicker
If Len(strFullName) > 0 Then
Else
MsgBox "You cancelled!"
Exit Sub
End If
'method 1
intFNum = FreeFile()
Open strFullName For Binary Access Read Lock Write As intFNum
lngReadPos = 1
For x = 1 To 4
Get #intFNum, x, BytGetHeader
hxValue = hxValue & Hex(BytGetHeader)
Next x
Close #intFNum
Debug.Print "Method 1: Header = " & hxValue
'method 2
hxValue = ""
avarBuffer = fnavarUseFileOpenToCreateBufferArr(strFullName)
For x = 0 To 3
hxValue = hxValue & Hex(avarBuffer(x))
Next x
Debug.Print "Method 2: Header = " & hxValue
Using a long in the same scenario results in -503326465, which has a hex value of FFFF FFFF E1FF D8FF
Bookmarks