Private Sub Command1_Click()
Dim i As Integer
Dim res As String
Dim Done As Boolean
Text5.Text = Val(Text1.Text) + Val(Text3.Text)
Temp = Text1.Text
Temp1 = Text1.Text
Do Until Temp \ 2 = 1
Temp = Temp \ 2
i = i + 1
Loop
If res = "" Then
For j = i + 1 To 0 Step -1
If Temp1 - 2 ^ j > 0 And Done = False Then
Temp1 = Temp1 - 2 ^ j
res = res & "1"
ElseIf Temp1 - 2 ^ j <> 0 And Done = False Then
res = res & "0"
ElseIf Temp1 - 2 ^ j = 0 And Done = False Then
res = res & "1"
Done = True
ElseIf Done = True Then
res = res & "0"
End If
Next
Text2.Text = res
End If
Dim Temp3, Temp4 As Long
Dim i34 As Integer
Dim res34 As String
Dim Done34 As Boolean
Temp3 = Text3.Text
Temp4 = Text3.Text
Do Until Temp3 \ 2 = 1
Temp3 = Temp3 \ 2
i34 = i34 + 1
Loop
If res34 = "" Then
For j = i34 + 1 To 0 Step -1
If Temp4 - 2 ^ j > 0 And Done34 = False Then
Temp4 = Temp4 - 2 ^ j
res34 = res34 & "1"
ElseIf Temp4 - 2 ^ j <> 0 And Done34 = False Then
res34 = res34 & "0"
ElseIf Temp4 - 2 ^ j = 0 And Done34 = False Then
res34 = res34 & "1"
Done34 = True
ElseIf Done34 = True Then
res34 = res34 & "0"
End If
Next
Text4.Text = res34
End If
Dim Temp5, Temp6 As Long
Dim i56 As Integer
Dim res56 As String
Dim Done56 As Boolean
Temp5 = Text5.Text
Temp6 = Text5.Text
Do Until Temp5 \ 2 = 1
Temp5 = Temp5 \ 2
i56 = i56 + 1
Loop
If res56 = "" Then
For j = i56 + 1 To 0 Step -1
If Temp6 - 2 ^ j > 0 And Done56 = False Then
Temp6 = Temp6 - 2 ^ j
res56 = res56 & "1"
ElseIf Temp6 - 2 ^ j <> 0 And Done56 = False Then
res56 = res56 & "0"
ElseIf Temp6 - 2 ^ j = 0 And Done56 = False Then
res56 = res56 & "1"
Done56 = True
ElseIf Done56 = True Then
res56 = res56 & "0"
End If
Next
Text6.Text = res56
End If
End Sub
Private Sub Command2_Click()
Dim Temp, Temp1 As Long
Dim i As Integer
Dim res As String
Dim Done As Boolean
Text5.Text = Val(Text1.Text) - Val(Text3.Text)
Temp = Text1.Text
Temp1 = Text1.Text
Do Until Temp \ 2 = 1
Temp = Temp \ 2
i = i + 1
Loop
If res = "" Then
For j = i + 1 To 0 Step -1
If Temp1 - 2 ^ j > 0 And Done = False Then
Temp1 = Temp1 - 2 ^ j
res = res & "1"
ElseIf Temp1 - 2 ^ j <> 0 And Done = False Then
res = res & "0"
ElseIf Temp1 - 2 ^ j = 0 And Done = False Then
res = res & "1"
Done = True
ElseIf Done = True Then
res = res & "0"
End If
Next
Text2.Text = res
End If
Dim Temp3, Temp4 As Long
Dim i34 As Integer
Dim res34 As String
Dim Done34 As Boolean
Temp3 = Text3.Text
Temp4 = Text3.Text
Do Until Temp3 \ 2 = 1
Temp3 = Temp3 \ 2
i34 = i34 + 1
Loop
If res34 = "" Then
For j = i34 + 1 To 0 Step -1
If Temp4 - 2 ^ j > 0 And Done34 = False Then
Temp4 = Temp4 - 2 ^ j
res34 = res34 & "1"
ElseIf Temp4 - 2 ^ j <> 0 And Done34 = False Then
res34 = res34 & "0"
ElseIf Temp4 - 2 ^ j = 0 And Done34 = False Then
res34 = res34 & "1"
Done34 = True
ElseIf Done34 = True Then
res34 = res34 & "0"
End If
Next
Text4.Text = res34
End If
Dim Temp5, Temp6 As Long
Dim i56 As Integer
Dim res56 As String
Dim Done56 As Boolean
Temp5 = Text5.Text
Temp6 = Text5.Text
Do Until Temp5 \ 2 = 1
Temp5 = Temp5 \ 2
i56 = i56 + 1
Loop
If res56 = "" Then
For j = i56 + 1 To 0 Step -1
If Temp6 - 2 ^ j > 0 And Done56 = False Then
Temp6 = Temp6 - 2 ^ j
res56 = res56 & "1"
ElseIf Temp6 - 2 ^ j <> 0 And Done56 = False Then
res56 = res56 & "0"
ElseIf Temp6 - 2 ^ j = 0 And Done56 = False Then
res56 = res56 & "1"
Done56 = True
ElseIf Done56 = True Then
res56 = res56 & "0"
End If
Next
Text6.Text = res56
End If
End Sub
Private Sub Command3_Click()
Dim Temp, Temp1 As Long
Dim i As Integer
Dim res As String
Dim Done As Boolean
Text5.Text = Val(Text1.Text) * Val(Text3.Text)
Temp = Text1.Text
Temp1 = Text1.Text
Do Until Temp \ 2 = 1
Temp = Temp \ 2
i = i + 1
Loop
If res = "" Then
For j = i + 1 To 0 Step -1
If Temp1 - 2 ^ j > 0 And Done = False Then
Temp1 = Temp1 - 2 ^ j
res = res & "1"
ElseIf Temp1 - 2 ^ j <> 0 And Done = False Then
res = res & "0"
ElseIf Temp1 - 2 ^ j = 0 And Done = False Then
res = res & "1"
Done = True
ElseIf Done = True Then
res = res & "0"
End If
Next
Text2.Text = res
End If
Dim Temp3, Temp4 As Long
Dim i34 As Integer
Dim res34 As String
Dim Done34 As Boolean
Temp3 = Text3.Text
Temp4 = Text3.Text
Do Until Temp3 \ 2 = 1
Temp3 = Temp3 \ 2
i34 = i34 + 1
Loop
If res34 = "" Then
For j = i34 + 1 To 0 Step -1
If Temp4 - 2 ^ j > 0 And Done34 = False Then
Temp4 = Temp4 - 2 ^ j
res34 = res34 & "1"
ElseIf Temp4 - 2 ^ j <> 0 And Done34 = False Then
res34 = res34 & "0"
ElseIf Temp4 - 2 ^ j = 0 And Done34 = False Then
res34 = res34 & "1"
Done34 = True
ElseIf Done34 = True Then
res34 = res34 & "0"
End If
Next
Text4.Text = res34
End If
Dim Temp5, Temp6 As Long
Dim i56 As Integer
Dim res56 As String
Dim Done56 As Boolean
Temp5 = Text5.Text
Temp6 = Text5.Text
Do Until Temp5 \ 2 = 1
Temp5 = Temp5 \ 2
i56 = i56 + 1
Loop
If res56 = "" Then
For j = i56 + 1 To 0 Step -1
If Temp6 - 2 ^ j > 0 And Done56 = False Then
Temp6 = Temp6 - 2 ^ j
res56 = res56 & "1"
ElseIf Temp6 - 2 ^ j <> 0 And Done56 = False Then
res56 = res56 & "0"
ElseIf Temp6 - 2 ^ j = 0 And Done56 = False Then
res56 = res56 & "1"
Done56 = True
ElseIf Done56 = True Then
res56 = res56 & "0"
End If
Next
Text6.Text = res56
End If
End Sub
Private Sub Command4_Click()
Dim Temp, Temp1 As Long
Dim i As Integer
Dim res As String
Dim Done As Boolean
Text5.Text = Val(Text1.Text) / Val(Text3.Text)
Temp = Text1.Text
Temp1 = Text1.Text
Do Until Temp \ 2 = 1
Temp = Temp \ 2
i = i + 1
Loop
If res = "" Then
For j = i + 1 To 0 Step -1
If Temp1 - 2 ^ j > 0 And Done = False Then
Temp1 = Temp1 - 2 ^ j
res = res & "1"
ElseIf Temp1 - 2 ^ j <> 0 And Done = False Then
res = res & "0"
ElseIf Temp1 - 2 ^ j = 0 And Done = False Then
res = res & "1"
Done = True
ElseIf Done = True Then
res = res & "0"
End If
Next
Text2.Text = res
End If
Dim Temp3, Temp4 As Long
Dim i34 As Integer
Dim res34 As String
Dim Done34 As Boolean
Temp3 = Text3.Text
Temp4 = Text3.Text
Do Until Temp3 \ 2 = 1
Temp3 = Temp3 \ 2
i34 = i34 + 1
Loop
If res34 = "" Then
For j = i34 + 1 To 0 Step -1
If Temp4 - 2 ^ j > 0 And Done34 = False Then
Temp4 = Temp4 - 2 ^ j
res34 = res34 & "1"
ElseIf Temp4 - 2 ^ j <> 0 And Done34 = False Then
res34 = res34 & "0"
ElseIf Temp4 - 2 ^ j = 0 And Done34 = False Then
res34 = res34 & "1"
Done34 = True
ElseIf Done34 = True Then
res34 = res34 & "0"
End If
Next
Text4.Text = res34
End If
Dim Temp5, Temp6 As Long
Dim i56 As Integer
Dim res56 As String
Dim Done56 As Boolean
Temp5 = Text5.Text
Temp6 = Text5.Text
Do Until Temp5 \ 2 = 1
Temp5 = Temp5 \ 2
i56 = i56 + 1
Loop
If res56 = "" Then
For j = i56 + 1 To 0 Step -1
If Temp6 - 2 ^ j > 0 And Done56 = False Then
Temp6 = Temp6 - 2 ^ j
res56 = res56 & "1"
ElseIf Temp6 - 2 ^ j <> 0 And Done56 = False Then
res56 = res56 & "0"
ElseIf Temp6 - 2 ^ j = 0 And Done56 = False Then
res56 = res56 & "1"
Done56 = True
ElseIf Done56 = True Then
res56 = res56 & "0"
End If
Next
Text6.Text = res56
End If
End Sub
Private Sub Command5_Click()
End
End Sub
'Private Sub Text1_KeyPress(KeyAscii As Integer)
'If (KeyAscii >= 48 And KeyAscii <= 57) Then
' ElseIf (KeyAscii = vbKeyReturn Or KeyAscii = vbKeyDelete) Then
' KeyAscii = 0
'ElseIf KeyAscii = vbKeyBack Then
'Else
'KeyAscii = 0
'MsgBox "You can only input numbers.", 64, "Error"
'Exit Sub
'End If
'End Sub
No comments:
Post a Comment