Click here to Skip to main content
16,020,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an excel macro. The macro converts the hex value entered in a cell.
When the cell has a value between 8FFF to FFFF, the conversion results in a negative integer.
For eg: FFFF is converted to -1.
The code part is given below:
VB
Dim IntVal As Long
IntVal = Val("&H" & hexVal) 
' hexVal is the value read from the cell(eg:- FFFF)

How can I convert the hex to a correct decimal? Please provide me a solution.
Posted
Updated 20-Dec-10 20:45pm
v2
Comments
JF2015 21-Dec-10 2:46am    
Edited to add code formatting.

1 solution

VB
Dim IntVal as Long
IntVal = Hex2Dec(hexVal)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900