Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can you do hex to decimal conversions in queries? 2

Status
Not open for further replies.

ScottyP

Technical User
Jun 6, 2001
3
US
I have a table with hexadecimal values in each record. I need to build a query that will convert the hex values to decimal values. Access 97 and 2000 have the "hex" function that does a decimal to hex conversion, but I do not know how to do the reverse. Ideas?

Thanks
 
This should do it for ya

Dim myval As Double

myval = Val("&Hffff&")

The &H****& tells the Val function that it being passed a Hex value.
 
Thanks Philly, but that only returns 65535, the decimal value of hex ffff. What I need is for it to return the decimal of the value in field "hexnumber" for example. I tried this before: val(&H[hexnumber]), but that didn't work.
 
You need to append the &H to the value of that field:

val("&H" & [hexnumber])

Try that... Terry M. Hoey
th3856@txmail.sbc.com
While I don't mind e-mail messages, please post all questions in these forums for the benefit of all members.
 
th3856,
That worked! Thanks a million, I've spent more time than I care to tell on this one.

 
FYI

val("&H" & [hexnumber] & "&")

forces positive numbers. Otherwise hex numbers begining with 8 thru F will return negative decimal numbers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top