1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Public Function ByteToFloat(InArray() As Byte) As Single
'Convert byte array to IEEE float
Dim PtrSource1 As Long
Dim PtrSource2 As Long
Dim PtrSource3 As Long
Dim PtrSource4 As Long
Dim PtrDest As Long
Dim DestVal As Single
'Memory location of float value
PtrDest = VarPtr(DestVal)
PtrSource1 = VarPtr(InArray(0))
PtrSource2 = VarPtr(InArray(1))
PtrSource3 = VarPtr(InArray(2))
PtrSource4 = VarPtr(InArray(3))
CopyMemory ByVal PtrDest, ByVal PtrSource1, 1
CopyMemory ByVal PtrDest + 1, ByVal PtrSource2, 1
CopyMemory ByVal PtrDest + 2, ByVal PtrSource3, 1
CopyMemory ByVal PtrDest + 3, ByVal PtrSource4, 1
ByteToFloat = CDbl(DestVal)
End Function |
Partager