Solved

# Problem converting HEX to Decimal

Posted on 2005-03-23
Medium Priority
233 Views
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
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
###### Suggested Courses
Course of the Month10 days, 21 hours left to enroll