证明1+1=3的vb代码
填个 text1,2,3和一个command1
Private Sub Command1_Click()
b = Bin(Val(Text1.Text))Text3.Text = Bin(Val(Text1.Text)) + Bin(Val(Text1.Text))
Text3.Text = BINtoDEC(Text3.Text)
End Sub
Function Bin(n As Long) As String
Do Until n = 0
Bin = (n Mod 2) & Bin
n = n \ 2
Loop
End Function
Public Function BINtoDEC(ByVal Bin As String) As Long
Dim i As Long
For i = 1 To Len(Bin)
BINtoDEC = BINtoDEC * 2 + Val(Mid(Bin, i, 1))
Next i
End Function