判斷吧,如果點(diǎn)擊+按鈕,則一個(gè)全局變量為1,-按鈕,則全局變量為2.以此類推,然后if或case判斷哪個(gè)數(shù),如果為1,就兩個(gè)數(shù)相加。
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到澤普網(wǎng)站設(shè)計(jì)與澤普網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、申請(qǐng)域名、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋澤普地區(qū)。
簡(jiǎn)單的說(shuō)拖出一些控件,設(shè)置相應(yīng)的caption和屬性等等,雙擊每個(gè)button控件,進(jìn)行相應(yīng)的處理,即可
我用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提取出來(lái)
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
你自己加窗體和空件吧
Private Sub a1_Click()
X = Val(Text1.Text)
Y = Val(Text2.Text)
s = X + Y
Text3.Text = s
Text3.Locked = True
End Sub
Private Sub a2_Click()
X = Val(Text1.Text)
Y = Val(Text2.Text)
s = X - Y
Text3.Text = s
Text3.Locked = True
End Sub
Private Sub a3_Click()
X = Val(Text1.Text)
Y = Val(Text2.Text)
s = X * Y
Text3.Text = s
Text3.Locked = True
End Sub
Private Sub a4_Click()
X = Val(Text1.Text)
Y = Val(Text2.Text)
s = X / Y
Text3.Text = s
Text3.Locked = True
End Sub
不會(huì)的叫我 在線談