jimmy0910 10 發表於 July 17, 2008 檢舉 Share 發表於 July 17, 2008 我想問一下要如何修改能連續做加減乘除運算,舉例來說就是1+2再按+它就直接幫你運算,以此類推!以下是只能做一次運算的程式碼,我該如何著手,或是有哪些重點有可以提一下~Public Class Form1 Dim temp_value As String Dim temp_pre As Integer Dim temp_op As Integer Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵1' Label1.Text = "1" Else Label1.Text = Label1.Text + "1" End If temp_pre = 0 End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵2' Label1.Text = "2" Else Label1.Text = Label1.Text + "2" End If temp_pre = 0 End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵3' Label1.Text = "3" Else Label1.Text = Label1.Text + "3" End If temp_pre = 0 End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵4' Label1.Text = "4" Else Label1.Text = Label1.Text + "4" End If temp_pre = 0 End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵5' Label1.Text = "5" Else Label1.Text = Label1.Text + "5" End If temp_pre = 0 End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵6' Label1.Text = "6" Else Label1.Text = Label1.Text + "6" End If temp_pre = 0 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵7' Label1.Text = "7" Else Label1.Text = Label1.Text + "7" End If temp_pre = 0 End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵8' Label1.Text = "8" Else Label1.Text = Label1.Text + "8" End If temp_pre = 0 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵9' Label1.Text = "9" Else Label1.Text = Label1.Text + "9" End If temp_pre = 0 End Sub Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click If (Label1.Text = "0" Or temp_pre > 0) Then '按鍵0' Label1.Text = "0" Else Label1.Text = Label1.Text + "0" End If temp_pre = 0 End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click temp_value = Label1.Text '按鍵+' temp_pre = 1 temp_op = 1 End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click temp_value = Label1.Text '按鍵-' temp_pre = 2 temp_op = 2 End Sub Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click temp_value = Label1.Text '按鍵*' temp_pre = 3 temp_op = 3 End Sub Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click temp_value = Label1.Text '按鍵/' temp_pre = 4 temp_op = 4 End Sub Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click If (temp_op = 1) Then '按鍵=' Label1.Text = CStr(CInt(temp_value) + CInt(Label1.Text)) ElseIf (temp_op = 2) Then Label1.Text = CStr(CInt(temp_value) + CInt(Label1.Text)) ElseIf (temp_op = 3) Then Label1.Text = CStr(CInt(temp_value) + CInt(Label1.Text)) ElseIf (temp_op = 4) Then Label1.Text = CStr(CInt(temp_value) + CInt(Label1.Text)) End If temp_pre = 5 temp_op = 5 End SubEnd Class 鏈接文章 分享到其他網站
damody 10 發表於 July 18, 2008 檢舉 Share 發表於 July 18, 2008 在下正在努力(工程型小算盤),但因有點複雜,難以一天解決。假如只要簡單版的可以立刻給您。 鏈接文章 分享到其他網站
damody 10 發表於 July 26, 2008 檢舉 Share 發表於 July 26, 2008 http://down.gogobox.com.tw/t2329175/ocuo2只有一些基本的功能,一。小數點二。正負號三。倒退鍵真的好複雜,不能直接code出來 = = 鏈接文章 分享到其他網站
Recommended Posts
請登入後來留意見
在登入之後,您才能留意見
立即登入