Questo un esempio di codice della funzione che dovresti usare, senza problemi di lunghezza e nell'ordine naturale in cui i byte sono presenti nella stringa ...
codice:
Private Function Hex2ByteArr(ByVal h As String) As Byte()
Dim sL As Long
Dim ix As Long
Dim bRes() As Byte
sL = Len(h)
If sL Then
ReDim bRes(0 To sL - 1)
For ix = 1 To sL - 1
bRes(ix - 1) = Val("&H" & Mid$(h, ix * 2 - 1, 2))
Next ix
End If
Hex2ByteArr = bRes
End Function
e questo un modo per chiamarla, tenendo presente sempre che la posizione 3 e' il byte 2 nel file ...
codice:
Put #1, 3, Hex2ByteArr("AABBCCDD")