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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a Hex to Decimal conversion function? 2

Status
Not open for further replies.

roymmira

Technical User
May 31, 2005
1
US
I'm new to Access, doing Query with the Builtin Functions but I didn't find the typical HEX2DEC, OCT2DEC, BIN2DEC etc that Excel offers. However they do appear in the Access HELP (as "worksheet functions"...).

Any ideas? Do the functions above appear in the Access HELP just because MSoft bundles up all Help info for their entire Office applications, and what I see in Help is really functions available in Excel only?
 
I don't beleive there is, but it's a pretty short function to write. Here is a sample I wipped up. Note that it doesn't check for spaces or have error handeling. Might work for you anyway.

ChaZ

Function Conv(HX As String) As Long
On Error Resume Next
Dim I As Long
Dim T As Long
Dim C As Long
C = 1
Dim Rslt As Double
For I = Len(HX) To 1 Step -1
T = Asc(Mid(HX, I, 1)) - 48
If T > 10 Then T = T - 7

Rslt = Rslt + (T * C)
If C = 1 Then C = 16 Else C = C * 16
Next I
Conv = Rslt
End Function


There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Blorf, a simpler way is to play with the Val function:
Val("&H" & HX)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, if you could hook a wire up to your forhead and give me some of your knowledge....

I didn't even think of Val as an option. Experience I guess.

Thanks,
ChaZ



There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top