哔哔one
Private Sub Command1_Click()Dim n As String, h As String, i As Integer, c As Stringn = Trim(Text1.Text)If Not (IsNumeric(n) And Val(n) > 0 And Int(n) = Val(n)) Then '判断n非数字、非正数、非整数情况MsgBox "输入数字符n非正整数,请确认退出!", vbOKOnlyExit SubEnd Ifh = Hex(Val(n)) '将n转换成16进制c = ""For i = 1 To Len(h)c = c & Hex2Bin(Mid(h, i, 1))NextPrint cEnd SubFunction Hex2Bin(ByVal str As String) '自定义函数16进制转换成2进制Select Case UCase(str)Case "0": Hex2Bin = "0000"Case "1": Hex2Bin = "0001"Case "2": Hex2Bin = "0010"Case "3": Hex2Bin = "0011"Case "4": Hex2Bin = "0100"Case "5": Hex2Bin = "0101"Case "6": Hex2Bin = "0110"Case "7": Hex2Bin = "0111"Case "8": Hex2Bin = "1000"Case "9": Hex2Bin = "1001"Case "A": Hex2Bin = "1011"Case "B": Hex2Bin = "1100"Case "C": Hex2Bin = "1101"Case "D": Hex2Bin = "1110"Case "E": Hex2Bin = "1111"End SelectEnd Function