View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Michel Pierron Michel Pierron is offline
external usenet poster
 
Posts: 214
Default Hexadecimal to Binary Conversion

Hi sean_f;

Private Function HexToBin$(HexNum$)
Dim i As Byte, B As String * 1
Dim lNum&: lNum = Val("&H" & HexNum)
Do
If lNum And 2 ^ i Then B = "1" Else B = "0"
HexToBin = B & HexToBin
i = i + 1
Loop Until 2 ^ i lNum
End Function

Sub Test
MsgBox HexToBin("00017FFF"), 64
End Sub

Regards,
MP


"sean_f" a écrit dans le message de news:
...
hi all,

does anyone know how to convert from hexadecimal
00017fff
or
3

to binary
00000000000000010111111111111111
or
011

Many Thanks
sean