可以将十进制转换成二进制
Public Function Bin(num) As String
Dim H As String
Dim s As Integer
H = Hex(num) '转成十六进制
Dim str, binstr As String
For i = 1 To Len(H)
str = Mid(H, i, 1)
Select Case str
Case "0"
binstr = binstr & "0000"
Case "1"
binstr = binstr & "0001"
Case "2"
binstr = binstr & "0010"
Case "3"
binstr = binstr & "0011"
Case "4"
binstr = binstr & "0100"
Case "5"
binstr = binstr & "0101"
Case "6"
binstr = binstr & "0110"
Case "7"
binstr = binstr & "0111"
Case "8"
binstr = binstr & "0100"
Case "9"
binstr = binstr & "1001"
Case "A"
binstr = binstr & "1010"
Case "B"
binstr = binstr & "1011"
Case "C"
binstr = binstr & "1100"
Case "D"
binstr = binstr & "1101"
Case "E"
binstr = binstr & "1110"
Case "F"
binstr = binstr & "1111"
End Select
Next i
For m = 1 To Len(binstr) '去除前面的几个0
str = Mid(binstr, m)
If s = 0 Then 's:判断第一个1
If str = "0" Then
binstr = Right(binstr, Len(binstr) - 1)
End If
End If
If str = "1" Then
s = 0
End If
Next m
Bin = binstr
End Function