簡(jiǎn)單的說拖出一些控件,設(shè)置相應(yīng)的caption和屬性等等,雙擊每個(gè)button控件,進(jìn)行相應(yīng)的處理,即可
為平邑等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計(jì)制作服務(wù),及平邑網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、平邑網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
我用VB做的你看能不能用
Public b
Public c
Public d
Public e
Public f
Private Sub Command14_Click()
d = ""
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Exit Sub
'c = Text1.Text
If b = "" Then Exit Sub
If e = "+" Then
d = f + b
Else
If e = "-" Then
d = f - b
Else
If e = "*" Then
d = f * b
Else
If e = "/" Then
If b = 0 Then
MsgBox "被除數(shù)不能為零!"
Exit Sub
End If
d = f / b
Else
MsgBox "錯(cuò)誤操作!"
End If
End If
End If
End If
Text1.Text = d
b = ""
c = ""
e = ""
End Sub
Private Sub Command15_Click()
Text1.Text = ""
b = ""
c = ""
d = ""
e = ""
f = ""
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
'判斷開頭有運(yùn)算符就清零
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判斷開頭有0就禁止輸入數(shù)字
If Text1.Text = "0" Then
Else
a = 1
'發(fā)現(xiàn)運(yùn)算結(jié)果就清零
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text '得到當(dāng)前操作數(shù)
End Sub
Private Sub Command2_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 2
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command3_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 3
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command4_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 4
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command5_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 5
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command6_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 6
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command7_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 7
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command8_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 8
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command9_Click()
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 9
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
End If
b = Text1.Text
End Sub
Private Sub Command10_Click()
If b = "" Then Exit Sub
a = "+"
e = "+"
f = b
Text1.Text = ""
Text1.Text = Text1.Text a
End Sub
Private Sub Command11_Click()
If b = "" Then Exit Sub
f = b
a = "-"
e = "-"
Text1.Text = ""
Text1.Text = Text1.Text a
End Sub
Private Sub Command12_Click()
If b = "" Then Exit Sub
a = "*"
e = "*"
f = b
Text1.Text = ""
Text1.Text = Text1.Text a
End Sub
Private Sub Command13_Click()
If b = "" Then Exit Sub
a = "/"
e = "/"
f = b '把操作數(shù)1提取出來
Text1.Text = ""
Text1.Text = Text1.Text a
End Sub
Private Sub Command16_Click()
'判斷有運(yùn)算符就清零
If Text1.Text = "+" Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判斷有零和空值就禁止輸入0
'發(fā)現(xiàn)運(yùn)算結(jié)果就清零
If d "" Then Text1.Text = "": d = ""
If Text1.Text = "0" Then
Else
a = 0
If d "" Then Text1.Text = "": d = ""
Text1.Text = Text1.Text a
b = Text1.Text
End If
End Sub
Public C護(hù)激篙刻蕻灸戈熏恭抹lass Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim c As Char
c = Trim(TextBox3.Text)
Select Case c
Case "+"
TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
Case "-"
TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
Case "*"
TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
Case "\"
If Val(TextBox2.Text) = 0 Then
MsgBox("分母為0")
Else
TextBox4.Text = Val(TextBox1.Text) \ Val(TextBox2.Text)
End If
Case "/"
If Val(TextBox2.Text) = 0 Then
MsgBox("分母為0")
Else
TextBox4.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
End If
End Select
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
計(jì)算機(jī)光要加減乘除的那種嗎?
先在窗口添加一個(gè)textbox文本框名字是textbox1,再添加一個(gè)標(biāo)簽,屬性text:(為一個(gè)空格)名字是label1,再加一個(gè)textbox文本框,名字是textbox2,加標(biāo)簽,名字是label2,屬性text:“=”(引號(hào)不算),在后面加一個(gè)文本框,名字為textbox3.下一行添加五個(gè)按鈕,名字分別是Button1(屬性text:加),Button2(屬性text:減).……最后一個(gè)是,清空,按鈕
雙擊Button1,輸入代碼:dim a,b,c as single(回車!)a=textbox1.text(!)b=textbox2.text(!)a+b=c(!),textbox3=c(!)
后面分別點(diǎn)擊不同的按鈕,把“+”改成“-”,“*”“/”行了
雙擊最后按鈕輸入textbox1=""(!)textbox2=""(!)textbox3=""就ok了,累死我了呵呵(?。┍硎净剀嚢?/p>
文章標(biāo)題:用vb.net做計(jì)算器 vb做一個(gè)計(jì)算器
標(biāo)題路徑:http://weahome.cn/article/dojgshj.html