timalex Posted February 2, 2001 Posted February 2, 2001 Hi Does anyone have a calculation up their sleeve that will convert a numeric value into hexadecimal? I've tried myself with a combination of built-in functions, but I'm not very good at math so it never comes out right. Thanks
BobWeaver Posted February 3, 2001 Posted February 3, 2001 Middle("0123456789ABCDEF",1+ Mod(Int(DecNum/16/16/16),16), 1) & Middle("0123456789ABCDEF",1+ Mod(Int(DecNum/16/16),16), 1) & Middle("0123456789ABCDEF",1+ Mod(Int(DecNum/16),16), 1) & Middle("0123456789ABCDEF", 1+Mod(DecNum,16), 1) ... where DecNum is the decimal number you want to convert. This will handle up to 65535 decimal or FFFF hex. If you need more digits, just append more terms on the beginning of the calculation. Add an additional /16 for each one. [This message has been edited by BobWeaver (edited February 02, 2001).]
timalex Posted February 3, 2001 Author Posted February 3, 2001 Bob Thanks a lot. I'd got all the right functions, but couldn't get my punctuation right!
timalex Posted February 3, 2001 Author Posted February 3, 2001 ...BTW How do I do it in reverse (hex to dec)?
BobWeaver Posted February 5, 2001 Posted February 5, 2001 (((Position("0123456789ABCDEF", Upper(Middle(HexNum, 1, 1)), 1, 1)-1)*16+ Position("0123456789ABCDEF", Upper(Middle(HexNum, 2, 1)), 1, 1)-1)*16+ Position("0123456789ABCDEF", Upper(Middle(HexNum, 3, 1)), 1, 1)-1)*16+ Position("0123456789ABCDEF", Upper(Middle(HexNum, 4, 1)), 1, 1)-1
Recommended Posts
This topic is 8764 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now