Problem converting HEX to Decimal

Posted on 2005-03-23
Medium Priority
Last Modified: 2010-04-23

This is a strange one...I am converting a hex number to decimal (from a serial stream, imagine that for those of you that have been following along at home), and as long as the number begins with a numeric number (0-9), it converts the number just fine.  BUT, if it starts with an alpha character, it gives me some odd ball negative number.  Anybody know why?

Here is the code:

        strHex8 = SplitUpString(8)
        ElapsedTime = (Val("&H" & strHex8) * 0.0001) / 3600

CE4A converts to -0.0003535...


2ED5 converts correctly to 0.000330277777777777777777...

What am I doing wrong?

Question by:indy500fan

Accepted Solution

wyoung76 earned 2000 total points
ID: 13611880
Have a look at this previous thread:


In summary try using this instead:

    CLng("&H" & strHex8)

Author Comment

ID: 13612855
Bingo!  That worked perfectly!  Thank you!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question