簡(jiǎn)單點(diǎn)的:
成都創(chuàng)新互聯(lián)主營(yíng)拱墅網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件開發(fā),拱墅h5小程序設(shè)計(jì)搭建,拱墅網(wǎng)站營(yíng)銷推廣歡迎拱墅等地區(qū)企業(yè)咨詢
dim 上一個(gè)數(shù) as double
dim 下一個(gè)數(shù) as double
dim 結(jié)果 as double
dim 操作 as string
private sub 加減乘除(byval sender as object, byval e as eventargs) handles 加.click, 減.click, 乘.click, 除.click
上一個(gè)數(shù) = cdbl(輸入框.text) ' 存儲(chǔ)當(dāng)前輸入的數(shù)值
輸入框.text = "" ' 等待下一個(gè)數(shù)值
select case sender.text ' 根據(jù)按下的按鈕的文本屬性確定你要做什么,這里可以用加減乘除號(hào)代替
case "加"
操作 = "加"
case "減"
操作 = "減"
case "乘"
操作 = "乘"
case "除"
操作 = "除"
end select
end sub
private sub 計(jì)算(byval sender as object, byval e as eventargs) handles 等號(hào).click
下一個(gè)數(shù) = 輸入框.text
輸入框.text = ”“
select case 操作
case "加"
結(jié)果 = 上一個(gè)數(shù) + 下一個(gè)數(shù)
case "減"
結(jié)果 = 上一個(gè)數(shù) - 下一個(gè)數(shù)
case "乘"
結(jié)果 = 上一個(gè)數(shù) * 下一個(gè)數(shù)
case "除"
結(jié)果 = 上一個(gè)數(shù) / 下一個(gè)數(shù)
end select
輸入框.text = cstr(結(jié)果)
上一個(gè)數(shù) = 結(jié)果
end sub
.NET 的哈,我沒有 .NET 現(xiàn)在,不知道行不行
1、在電腦桌面打開軟件“Visual Basic”,新建一個(gè)文件
2、放置3個(gè)“Text”部件和4個(gè)“Command”部件,調(diào)整好位置;
3、對(duì)這7個(gè)小部件進(jìn)行修飾,更改command部件的名稱為“+、-、*、/”方便識(shí)別,清除“Test”部件里的內(nèi)容;
4、雙擊“Command”部件進(jìn)入編輯頁(yè)面,輸入圖中所示的命令;
5、命令輸完以后,關(guān)閉編輯頁(yè)面,運(yùn)轉(zhuǎn)程序,在前兩個(gè)方框上輸出數(shù)字,只要點(diǎn)擊下方的“+、-、*、/、”四個(gè)部件,第三個(gè)方框就會(huì)表現(xiàn)成果,實(shí)現(xiàn)加減乘數(shù)運(yùn)算。
先在form上建立三個(gè)textbox,分別為textbox1,textbox2,textbox3,再建立四個(gè)按鈕,分別為cmdplus,cmdminus,cmdmultiple,cmddivide,代碼如下:
Private Sub cmdplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdplus.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a + b
End If
Private Sub cmdminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdminus.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a - b
End If
Private Sub cmdmultiple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdmultiple.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a * b
End If
Private Sub cmddivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmddivide.Click
Dim a As Integer
Dim b As Integer
a = TextBox1.Text
b = TextBox2.Text
TextBox3.Text = a / b
End If