AboutAlex Barry Expertise I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.
Experience Hobby programming since 2000
I no longer belong to any community programming groups, but do have knowledge of *basic dialect and C/C++
Expert: Alex Barry Date: 7/3/2008 Subject: Convert from Hex to Dec from serial poll
Question I am talking serially to a power supply I send a command and I get a response that says ADDR:1A ERROR 00 80 C9 12 B0 FE. It's the hex response value of the power supply. This is what I get when I send the same command in Hyperterm. Looks good so far. So I do a V=VAL(MID$(a$,25,2))in my program and it gives me 12 as I would expect but when I try to get C9 It comes back as 9 only, I'm not sure how to get the value C because I guess it's looking for a numeric not a character. Any help??
Answer Hi, Mike,
c9 = VAL( "&h" + MID$(a$,21,2) )
VAL will trim all the alpha-characters, so it's only numbers.
Adding the "&h" will convert it to a hex value, then the value should be the decimal representation of the hex value