Solved

# Problem converting HEX to Decimal

Posted on 2005-03-23
Medium Priority
236 Views
Last Modified: 2010-04-23
Friends,

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...

However,

2ED5 converts correctly to 0.000330277777777777777777...

What am I doing wrong?

0
Question by:indy500fan
2 Comments

LVL 4

Accepted Solution

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

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20831640.html

In summary try using this instead:

CLng("&H" & strHex8)
0

Author Comment

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

## Featured Post

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.