CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Problem with Converting a Hex to Double

    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.




  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Problem with Converting a Hex to Double

    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





  3. #3
    Guest

    Re: Problem with Converting a Hex to Double

    Thanks a Lot I wrote a similar function to do that. But why is that problem?

    Thanks for the reply.

    Srini


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured