VB中十进制转换成十六进制的程序怎么写~
题目给了十进制转换成二进制的程序根据它编写十进制转化成十六进制的程序~不会呀~PrivateSubForm_Load()n=Val(InputBox("请输入要转换的十进...
题目给了十进制转换成二进制的程序 根据它编写十进制转化成十六进制的程序~不会呀~
Private Sub Form_Load()
n = Val(InputBox("请输入要转换的十进制数整数"))
m = n
x = ""
Do While n <> 0
a = n Mod 2
n = n \ 2
x = a & x
Loop
MsgBox m & "换成二进制数是:" & x
End Sub
是不是太长了………………晕 展开
Private Sub Form_Load()
n = Val(InputBox("请输入要转换的十进制数整数"))
m = n
x = ""
Do While n <> 0
a = n Mod 2
n = n \ 2
x = a & x
Loop
MsgBox m & "换成二进制数是:" & x
End Sub
是不是太长了………………晕 展开
1个回答
展开全部
Private Sub Form_Load()
n = Val(InputBox("请输入要转换的十进制数整数"))
m = n
x = "" :Y=""
Do While n <> 0
a = n Mod 2
n = n \ 2
x = a & x
Loop
MsgBox m & "换成二进制数是:" & x
Do While Len(X) Mod 4 <> 0
X = "0" + X
Loop
Do While Len(X) > 0
Select Case Right(X, 4)
Case "0000"
y= "0" + y
Case "0001"
y= "1" + y
Case "0010"
y = "2" + y
Case "0011"
y = "3" + y
Case "0100"
y = "4" + y
Case "0101"
y = "5" + y
Case "0110"
y = "6" + y
Case "0111"
y = "7" + y
Case "1000"
y = "8" + y
Case "1001"
y = "9" + y
Case "1010"
y = "A" + y
Case "1011"
y = "B" +y
Case "1100"
y = "C" + y
Case "1101"
y = "D" + y
Case "1110"
y = "E" + y
Case "1111"
y = "F" + y
End Select
X = Left(X, Len(X) - 4)
Loop
MsgBox m & "换成十六进制数是:" & y
End Sub
n = Val(InputBox("请输入要转换的十进制数整数"))
m = n
x = "" :Y=""
Do While n <> 0
a = n Mod 2
n = n \ 2
x = a & x
Loop
MsgBox m & "换成二进制数是:" & x
Do While Len(X) Mod 4 <> 0
X = "0" + X
Loop
Do While Len(X) > 0
Select Case Right(X, 4)
Case "0000"
y= "0" + y
Case "0001"
y= "1" + y
Case "0010"
y = "2" + y
Case "0011"
y = "3" + y
Case "0100"
y = "4" + y
Case "0101"
y = "5" + y
Case "0110"
y = "6" + y
Case "0111"
y = "7" + y
Case "1000"
y = "8" + y
Case "1001"
y = "9" + y
Case "1010"
y = "A" + y
Case "1011"
y = "B" +y
Case "1100"
y = "C" + y
Case "1101"
y = "D" + y
Case "1110"
y = "E" + y
Case "1111"
y = "F" + y
End Select
X = Left(X, Len(X) - 4)
Loop
MsgBox m & "换成十六进制数是:" & y
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询