Thread: HEX2BIN
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default HEX2BIN

...I also need to maintain the leading 0's. 001

Just another of many variations:

Function HexToBin(HexString As String) As String
'// Dana DeLouis
Dim j As Long
Dim n As Long
Dim Bin As String

For j = Len(HexString) To 1 Step -1
n = Asc(UCase(Mid$(HexString, j, 1))) - 48 '0-9, or 17-22
If n 9 Then n = n - 7 '0-15
Bin = Sgn(n And 8) & Sgn(n And 4) & Sgn(n And 2) & Sgn(n And 1) &
Bin
Next j
HexToBin = Bin
End Function

--
Dana DeLouis
Windows XP, Office 2003


"Dan" wrote in message
...
I have seen a few posting on this topic but they all have the same short
fall. I need a conversion that can handle a hex value from 00 to
FFFFFFFF7B00FF4000. I also need to maintain the leading 0's. 001 =
000000000001

Any ideas?

Thanks