'INPUT: It is a hexadecimal number of eight characters
'RETURN: Single Floating Point
 Function HextoFloatIEEE(txt As String) As Single
        Dim out As Single
        Try
            Dim by(3) As Byte
            Dim i As Integer
            For i = 0 To 3
                by(i) = Convert.ToInt32(txt.Substring(i * 2, 2), 16)
            Next

            Array.Reverse(by)
            out = BitConverter.ToSingle(by, 0)
        Catch ex As Exception
            out = 0
        End Try
        Return out
    End Function

'How to use it:
Dim convert As Single = HextoFloatIEEE("44AC6353")' Result: 1379.10388
Advertisements