octal | binary | decimal | hexadecimal | Convert public Function d_to_b (ByVal Dec as Long) as String
Todo
D_to_b = Dec Mod 2 & D_to_b
Dec = Dec \ 2
Loop while Dec
End Function
Public Function b_to_d (ByVal Bin as String) as Integer
Dim I as Long
For i = 1 to Len (Bin)
B_to_d = b_to_d * 2 + Val (Mid (Bin, I, 1))
Next I
End Function
Public Function H_to_b (ByVal Hex As String) as String
Dim I as Long
Dim B as String
Hex = UCase (Hex)
For i = 1 to Len (HEX)
Select Case Mid (Hex, I, 1)
Case "0": B = b & "0000"
Case "1": B = B & "0001"
Case "2": b = B & "0010"
Case "3": b = B & "0011"
Case "4": b = B & "0100"
Case "5": B = B & "0101"
Case "6": B = B & "0110"
Case "7": B = B & "0111"
Case "8": B = B & "1000"
Case "9": B = B & "1001"
Case "A": b = B & "1010"
Case "B": b = B & "1011"
Case "C": b = B & "1100"
Case "D": b = B & "1101"
Case "E": b = B & "1110"
Case "F": b = B & "1111"
End Select
Next I
While left (B, 1) = "0"
B = Right (b, Len (b)-1)
Wend
H_to_b = B
End Function
Public Function B_to_h (ByVal Bin As String) as String
Dim I as Long
Dim H as String
If Len (Bin) Mod 4 <> 0 Then
Bin = String (4-len (BIN) Mod 4, "0") & Bin
End If
For i = 1 to Len (Bin) Step 4
Select Case Mid (Bin, I, 4)
Case "0000": H = h & "0"
Case "0001": H = h & "1"
Case "0010": H = h & "2"
Case "0011": H = H & "3"
Case "0100": H = H & "4"
Case "0101": H = h & "5"
Case "0110": H = h & "6"
Case "0111": H = h & "7"
Case "1000": H = h & "8"
Case "1001": H = h & "9"
Case "1010": H = h & "A"
Case "1011": H = h & "B"
Case "1100": H = h & "C"
Case "1101": H = h & "D"
Case "1110": H = h & "E"
Case "1111": H = h & "F"
End Select
Next I
B_to_h = H
End Function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.