我编的,不知道对不对,顺便把8,16也加了 Private Sub Text1_Change() If IsNumeric(text1.Text) = 0 Then text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" ElseIf text1.Text > 999999999 Then text1.Text = 999999999 Else x = text1.Text Do If x = 1 And a = 0 Then s = Str$(x) Else y = Int(x / 2) z = Str$(x - y * 2) s = z + s x = y a = 0 a = a + 1 End If If x = 1 And a > 0 Then s = Str$(x) + s End If Loop While x > 1 Text4.Text = Val(s) Text3.Text = Hex$(text1.Text) Text2.Text = Oct$(text1.Text) End If End Sub
还没答案??只好我出手了请看好: Private Sub Command1_Click() Dim a As Integer Dim s As String s = "" a = Text1.Text '从界面10进制取数 Do While True If a = 1 Then s = (a Mod 2) & s Text2.Text = s '将二进制结果显示到界面 Exit Do End If s = (a Mod 2) & s a = a \ 2 Loop End Sub 上面代码我已经调试通过可要记得给分呀注意上述算法只是纯10进制向2进化不考虑其它限制。
Private Sub Text1_Change()
If IsNumeric(text1.Text) = 0 Then
text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
ElseIf text1.Text > 999999999 Then
text1.Text = 999999999
Else
x = text1.Text
Do
If x = 1 And a = 0 Then
s = Str$(x)
Else
y = Int(x / 2)
z = Str$(x - y * 2)
s = z + s
x = y
a = 0
a = a + 1
End If
If x = 1 And a > 0 Then
s = Str$(x) + s
End If
Loop While x > 1
Text4.Text = Val(s)
Text3.Text = Hex$(text1.Text)
Text2.Text = Oct$(text1.Text)
End If
End Sub
Private Sub Command1_Click()
Dim a As Integer
Dim s As String
s = ""
a = Text1.Text '从界面10进制取数
Do While True
If a = 1 Then
s = (a Mod 2) & s
Text2.Text = s '将二进制结果显示到界面
Exit Do
End If
s = (a Mod 2) & s
a = a \ 2
Loop
End Sub
上面代码我已经调试通过可要记得给分呀注意上述算法只是纯10进制向2进化不考虑其它限制。