Isn't there a function that converts HEX to BIN?
Printable View
Isn't there a function that converts HEX to BIN?
Hex to bin is really easy to do just remember this
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
A = 1010
B = 1011
C = 1100
D = 1101
E = 1110
F = 1111
Hope this helps,
This function will convert any decimal number 0 to 255 to its binary equivilant.
HTHCode:Public Function convertBinary(Number As Byte) As String
Dim I As Byte, bStr As String
For I = 0 To 7
If (Number And (2 ^ I)) = (2 ^ I) Then
bStr = bStr & "1"
Else
bStr = bStr & "0"
End If
Next I
convertBinary = StrReverse(bStr)
End Function
G
Or this one (with out the strReverse function DOH)
HTHCode:
Quote:
Public Function convertBinary(Number As Byte) As String
Dim I As Byte
For I = 0 To 7
If (Number And (2 ^ I)) = (2 ^ I) Then
convertBinary = "1" & convertBinary
Else
convertBinary = "0" & convertBinary
End If
Next I
End Function
G
This will convert Hex to Bin.
VB Code:
Public Function Hex2Bin(ByVal dwHex As String) As String dwHex = CStr(dwHex) Dim sTemp As String For I = 1 To Len(dwHex) sTemp = Mid(dwHex, I, 1) Select Case sTemp Case "0": Hex2Bin = Hex2Bin & "0000" Case "1": Hex2Bin = Hex2Bin & "0001" Case "2": Hex2Bin = Hex2Bin & "0010" Case "3": Hex2Bin = Hex2Bin & "0011" Case "4": Hex2Bin = Hex2Bin & "0100" Case "5": Hex2Bin = Hex2Bin & "0101" Case "6": Hex2Bin = Hex2Bin & "0110" Case "7": Hex2Bin = Hex2Bin & "0111" Case "8": Hex2Bin = Hex2Bin & "1000" Case "9": Hex2Bin = Hex2Bin & "1001" Case "A": Hex2Bin = Hex2Bin & "1010" Case "B": Hex2Bin = Hex2Bin & "1011" Case "C": Hex2Bin = Hex2Bin & "1100" Case "D": Hex2Bin = Hex2Bin & "1101" Case "E": Hex2Bin = Hex2Bin & "1110" Case "F": Hex2Bin = Hex2Bin & "1111" End Select Next I End Function
Thanks everybody..............