AllExperts > Experts 
Search      

Qbasic, Quickbasic

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex 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++
 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > Convert from Hex to Dec from serial poll

Topic: Qbasic, Quickbasic



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

Hope that helps,
Alex

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.