My machine is little-endian (Intel byte order). I need to read a binary file containing 16-bit signed integer data in Motorola/IEEE byte order (\"big-endian\"), then do some
By using simple bitwise logic.
Public Function SwapBytes(ByVal i As Integer) As Integer
Dim b1 As Byte, b2 As Byte
b1 = i And &HFF
If i And &H8000 Then
b2 = ((i And &H7F00) / 256) Or &H80
Else
b2 = (i And &HFF00) / 256
End If
If b1 And &H80 Then
SwapBytes = (b1 And &H7F) * 256 Or b2 Or &H8000
Else
SwapBytes = b1 * 256 Or b2
End If
End Function
Well, not so simple due to VBA limitations. Still, I believe that will be much faster than calling CopyMemory function twice.