Hi All, How to convert Hexadecimal to decimal? I've tried use Val() to get the value but some value is not valid Help me please..
Hi All, How to convert Hexadecimal to decimal? I've tried use Val() to get the value but some value is not valid Help me please..
Your question although specific is what you want is a little complicated, also missing some information.
Do you want to convert it for every entry in a table, or do you just want it to convert one number at a time?
Are the numbers fixed length or variable?
Are the numbers stored as a single string (if appropriate)?
Val returns the numbers in a string and stops returning numbers once it hits a non numeric character, see http://www.techonthenet.com/access/f...umeric/val.php
A paper method for converting hexadecimal to decimal is located at http://www.webelfin.com/webelfindesign/hexdec.html (first example)
With a bit more clarification we might be able to help a bit more.
Yes, I want to convert it for every entry in a table, and the numbers is fixed length, just a simple program.
Now I use command Val("&h" & [FieldName]). only a few results that have the wrong values, most of the results are correct, as I said before.
for example : 9FD9 (Hex) after we convert to decimal the result should be 40921 (Dec), but in my query the result is -24615
Do I need a complex script or just need a basic command in MS. Access?
Many Thanks!
see http://support.microsoft.com/kb/161304
Code:Function HexToLong(ByVal sHex As String) As Long HexToLong = Val("&H" & sHex & "&") End Function
This is why i love orange!
Great!! problem has been solved by orangesee http://support.microsoft.com/kb/161304
Code:Function HexToLong(ByVal sHex As String) As Long HexToLong = Val("&H" & sHex & "&") End Function
Thanks Master!!!