寻求vb达人帮助
我只要输入一个十进制的数,然后点击显示,分别出来其他进制的数。
一个是输入文本,一个是显示按钮,还有三个是八进制,十六进制,十二进制的显示窗 展开
这是我写的一个程序,是2,8,10,16进制进行转换的,楼主可以自己再思考一下,本程序只有两个文本框,一个输入,一个显示
Private Sub Command1_Click() '二进制
Dim i As Integer
Dim a As Long
Dim b As String
a = Val(Text1.Text)
Do
i = a Mod 2
a = a \ 2
b = i & b
Loop While a > 0
Text2.Text = b
End Sub
Private Sub Command2_Click() '八进制
Dim i As Integer
Dim a As Long
Dim b As String
a = Val(Text1.Text)
Do
i = a Mod 8
a = a \ 8
b = i & b
Loop While a > 0
Text2.Text = b
End Sub
Private Sub Command3_Click() ’十六进制
Dim i As Integer
Dim a As Long
Dim b As String
a = Val(Text1.Text)
Do
i = a Mod 16
a = a \ 16
If i >= 10 Then
b = Chr(55 + i) & b
Else
b = i & b
End If
Loop While a > 0
Text2.Text = b
End Sub
Private Sub Command4_Click() '退出
Unload Me
End Sub
如有不足,请楼主指正
有几个自带的函数
Hex
Oct