SwingeyP
Member
Hello again.
I have a 'word' value which could contain any 4 digits for example 6F12 (the number can change)
I want to convert this to the ascii equivalent of the number, so 6=0x36, F= 0x46, 1=0x31, 2=0x32
how do I do it?
My attempt ...
It's not quite right - any ideas?
Regards - Paul
I have a 'word' value which could contain any 4 digits for example 6F12 (the number can change)
I want to convert this to the ascii equivalent of the number, so 6=0x36, F= 0x46, 1=0x31, 2=0x32
how do I do it?
My attempt ...
Code:
Dim value As Word
Dim b1 As Byte
Dim b2 As Byte
Dim b3 As Byte
Dim b4 As Byte
value = 0x6f12
b1 = ShiftRight(value, 12)
b1 = b1 And 0x0f
b1 = b1 + 0x30
b2 = ShiftRight(value, 8)
b2 = b2 And 0x0f
b2 = b2 + 0x30
b3 = ShiftRight(value, 4)
b3 = b3 And 0x0f
b3 = b3 + 0x30
b4 = ShiftRight(value, 0)
b4 = b4 And 0x0f
b4 = b4 + 0x30
It's not quite right - any ideas?
Regards - Paul