Displaying hexadecimal data as float. What sort of result are you after?
I have a SQL Server database that gets a large C++ data structure that contains longs and floats serialized as an ASCII string where all bytes were converted to hex. The bytes have to be reversed because of endieness. I have been tasked with creating a page to dispaly the parsed data. I know that I can extract the data in groups of 4 (for the longs) and 8 (for the floats). I can convert the hex to decimal, but it is converting to a very large integer type value instead of the expected decimal. I have tried to search the web, but have found very little to aid. The closest used a function similar to the C++ memcpy. This did not seem to be available in my case.
A sample of the code is here:
MyDataReader.Read()
' extract the data
Dim dataString As String
Dim tempString As String
Dim counter As Long
Dim tempInt As Long
Dim tempFloat As Double
counter = 0
dataString = CStr(MyDataReader("fld_Curve_Data"))
Dim tRow As New TableRow()
tempString = "&H" + dataString.Substring(counter + 2, 1) + dataString.Substring(counter + 3, 1) + dataString.Substring(counter + 0, 1) + dataString.Substring(counter + 1, 1)
tempInt = CInt(tempString)
counter = counter + 4
tempString = "&H" + dataString.Substring(counter + 2, 1) + dataString.Substring(counter + 3, 1) + dataString.Substring(counter + 0, 1) + dataString.Substring(counter + 1, 1)
tempInt = Val(tempString)
counter = counter + 4
Dim tCell0 As New TableCell()
tCell0.Text = CStr(tempInt)
tRow.Cells.Add(tCell0)
tempString = "&H" + dataString.Substring(counter + 2, 1) + dataString.Substring(counter + 3, 1) + dataString.Substring(counter + 0, 1) + dataString.Substring(counter + 1, 1)
tempInt = Val(tempString)
counter = counter + 4
Dim tCell1 As New TableCell()
tCell1.Text = CStr(tempInt)
tRow.Cells.Add(tCell1)
tempString = "&H" + dataString.Substring(counter + 6, 1) + dataString.Substring(counter + 7, 1) + dataString.Substring(counter + 4, 1) + dataString.Substring(counter + 5, 1) + dataString.Substring(counter + 2, 1) + dataString.Substring(counter + 3, 1) + dataString.Substring(counter + 0, 1) + dataString.Substring(counter + 1, 1)
tempFloat = Val(tempString)
counter = counter + 8
Dim tCell2 As New TableCell()
tCell2.Text = CStr(tempFloat)
tRow.Cells.Add(tCell2)

