>Come on, guys... My question was
>clear.
>
>What is the *equation* used for
>decimal to hexa conversion. Anyone
>knows it?
I've got a working program in C/C++.
Basically you divide the number by a power of 16, one that divides into the number less than 16 times (or you must choose a higher power), then take that number and convert it to hex (0123456789ABCDEF). Then subtract that value * 16^power, and repeat with a lower-order power.
Ex:
[pre]
for i = 10 to 1, step -1
{
Temp = Number / (16^i)
if Temp = 0, HexNumber:Character(i) = '0'
if Temp = 1, HexNumber:Character(i) = '1'
...
if Temp = 15, HexNumber:Character(i) = 'F'
Number = Number - (Temp * (16^i))
}
[/pre]
I had to make it (i-1) in my equations (but not the for loop) for it to work properly.
>It is for a VB program,
>why?
Because some of us have source code for certain languages like C/C++.
You may consider using a function like HEX() in VB if there is one. No use reprogramming the wheel.
-Xotor-
[div align=center]
http://www.poseidonet.f2s.com/files/nostupid.gif
[/div]