Can anyone tell me if there is an inverse function to the Hex() function (one that converts hexadecimal back to decimal. Thanks.
Jay D Zimmerman
Printable View
Can anyone tell me if there is an inverse function to the Hex() function (one that converts hexadecimal back to decimal. Thanks.
Jay D Zimmerman
Just use &H?, where ? is the hexadecimal number.
[Edited by Iain17 on 05-23-2000 at 04:46 PM]Code:MsgBox &H100
'displays 256
How can I use this function in coordination with a variable?
'Theres probably only one way strings containing hex can be converted to decimal
Code:Function unhex(hex)
a = Left(hex, 1)
If a >= "A" Then a = Asc(a) - 55
B = Right(hex, 1)
If B >= "A" Then B = Asc(B) - 55
unhex = Chr(a * 16 + B)
End Function
it's easier than that... just do this since we know a HEX result is a string
Code:
'' assumes HEX value has no id prefex ie 0x or &H
Public Function HEX2DEC(ByRef hex_str As String) as Long
HEX2DEC = CLng("&H" & hex_str)
End Function