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
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
  • Learn & ask questions

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

770 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