by Luis (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 25th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This would convert any hexadecimal number to binary without any error
Dim Bin, Res As String
Dim a As Integer
For a = Val(Len(Trim(Text1.Text))) To 1 Step -1
Select Case Mid(Numero, a, 1)
Case "0": Bin = "0000"
Case "1": Bin = "0001"
Case "2": Bin = "0010"
Case "3": Bin = "0011"
Case "4": Bin = "0100"
Case "5": Bin = "0101"
Case "6": Bin = "0110"
Case "7": Bin = "0111"
Case "8": Bin = "1000"
Case "9": Bin = "1001"
Case "A": Bin = "1010"
Case "B": Bin = "1011"
Case "C": Bin = "1100"
Case "D": Bin = "1101"
Case "E": Bin = "1110"
Case "F": Bin = "1111"
Case Else
m = MsgBox("Su numero no es Hexadecimal", vbCritical, "Error")
End Select
Res = Bin + Res
Next a
For a = 1 To Len(Res)
If Mid(Res, a, 1) = "1" Then Exit For
Next a
Res = Mid(Res, a, Len(Res) - a + 1)
HexToBin = Res
End Function
No comments have been posted about This would convert any hexadecimal number to binary without any error. Why not be the first to post a comment about This would convert any hexadecimal number to binary without any error.