- 最後登錄
- 2023-10-13
- 在線時間
- 0 小時
- 註冊時間
- 2007-7-30
- 閱讀權限
- 95
- 精華
- 0
- UID
- 1967155
- 帖子
- 570
- 積分
- 1520 點
- 潛水值
- 40073 米
| 本帖最後由 benny_2649 於 2012-3-9 05:05 PM 編輯
- Public Class Form1
- Dim tmp As Integer
- Dim num1 As Integer
- Dim num2 As Integer
- Dim time As Integer
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 1
- Else
- TextBox1.Text &= 1
- End If
- num2 = 1
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 2
- Else
- TextBox1.Text &= 2
- End If
- num2 = 2
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 3
- Else
- TextBox1.Text &= 3
- End If
- num2 = 3
- End Sub
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 4
- Else
- TextBox1.Text &= 4
- End If
- num2 = 4
- End Sub
- Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 5
- Else
- TextBox1.Text &= 5
- End If
- num2 = 5
- End Sub
- Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 6
- Else
- TextBox1.Text &= 6
- End If
- num2 = 6
- End Sub
- Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 7
- Else
- TextBox1.Text &= 7
- End If
- num2 = 7
- End Sub
- Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 8
- Else
- TextBox1.Text &= 8
- End If
- num2 = 8
- End Sub
- Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 9
- Else
- TextBox1.Text &= 9
- End If
- num2 = 9
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- TextBox1.Text &= 0
- If Val(TextBox1.Text) = 0 Then
- TextBox1.Text = 0
- End If
- num2 = 0
- End Sub
- Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
- tmp = 1
- num1 = Val(TextBox1.Text)
- TextBox1.Text = ""
- End Sub
- Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
- tmp = 2
- num1 = Val(TextBox1.Text)
- TextBox1.Text = ""
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- tmp = 3
- num1 = Val(TextBox1.Text)
- TextBox1.Text = ""
- End Sub
- Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
- tmp = 4
- num1 = Val(TextBox1.Text)
- TextBox1.Text = ""
- End Sub
- Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
- time = 1 + time
- If 1 = tmp Then
- TextBox1.Text = num2 + num1
- ElseIf 2 = tmp Then
- TextBox1.Text = num1 - num2
- ElseIf 3 = tmp Then
- TextBox1.Text = num2 * num1
- ElseIf 4 = tmp Then
- TextBox1.Text = num1 / num2
- End If
- If 1 = tmp And time > 1 Then
- TextBox1.Text = num2 + Val(TextBox1.Text)
- ElseIf 2 = tmp And time > 1 Then
- TextBox1.Text = num1 - num2
- ElseIf 3 = tmp And time > 1 Then
- TextBox1.Text = num2 * num1
- ElseIf 4 = tmp And time > 1 Then
- TextBox1.Text = num1 / num2
- End If
- End Sub
- Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
- TextBox1.Text = ""
- num1 = 0
- num2 = 0
- tmp = 0
- time = 0
- End Sub
- End Class
複製代碼
我的問題在於計算機"="的部分我希望它可以有連續計算的功能
我想要的功能是 按下"="後 A+B=C 再按一次就是C+B=C .........
可是用宣告一個全域變數"time"來計算我按了幾次"="
大於2次的化就開始用C+B=C
可是我在測試時,我也抓不到是哪邊有錯
time有一直往上加上去,tmp也一直保持在1 ←"+"的意思
可是我的"="判斷的地方還是沒有出來我要的功能
... |
|