HEX2BIN
"Dan" skrev i en meddelelse
...
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
Hi Dan
This UDF will convert any hex number to its binary equivalent.
Function HexToBin(HStr As String) As String
'Leo Heuser, Sept. 2006
'Example: =hextobin("67F")
Dim Counter As Long
Dim Counter1 As Long
Dim Digits As String
Dim DStr As String
Digits = "0123456789ABCDEF"
HStr = UCase(HStr)
For Counter = Len(HStr) To 1 Step -1
DStr = InStr(Digits, Mid$(HStr, Counter, 1)) - 1
For Counter1 = 1 To 4
HexToBin = Mid$(Digits, DStr - Int(DStr / 2) * _
2 + 1, 1) & HexToBin
DStr = Int(DStr / 2)
Next Counter1
Next Counter
End Function
--
Best regards
Leo Heuser
Followup to newsgroup only please.
|