Click to See Complete Forum and Search --> : Problem with Converting a Hex to Double


August 9th, 1999, 01:09 PM
Hi,
I am having problem converting the hex string into double using CDbl function. I am trying to convert this string "ff90e5ed" but Cdbl returns this -7281171. It is really straight forward. I really dont know what is wrong with it. If any of U know mail me how to solve this.

Lothar Haensler
August 10th, 1999, 02:55 AM
this code gives you the correct result.

private Sub Command1_Click()

MsgBox cvt("&Hff90e5ed")
End Sub
private Function cvt(byval strHex as string) as Double
Dim i as Integer
Dim result as Double
Dim j as Integer
for i = len(strHex) to 3 step -1
result = result + CInt("&H" & mid(strHex, i, 1)) * 16 ^ j
j = j + 1
next i
cvt = result

End Function

August 17th, 1999, 01:54 PM
Thanks a Lot I wrote a similar function to do that. But why is that problem?

Thanks for the reply.

Srini