求用vb编写一个简易计算器的程序代码

如题所述

第1个回答  2010-12-24
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
Label1.Caption = "+"
End Sub

Private Sub Command2_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
Label1.Caption = "-"
End Sub

Private Sub Command3_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
Label1.Caption = "*"
End Sub

Private Sub Command4_Click()
Text3.Text = Val(Text1.Text) \ Val(Text2.Text)
Label1.Caption = "\"
End Sub

Private Sub Command5_Click()
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
End Sub
第2个回答  2010-12-23
界面:
text1
1 2 3 +
4 5 6 -
7 8 9 *
0 = AC /
代码:
dim newnum as boolean
dim n1,n2 op as integer
private sub ac_click()
text1.text=""
end sub
private sub command1_click(index as integer)
if newnum=true then text1=""
text1=text1&index
newnum=false
end sub
private sub command1_click(index as integer)
if op=0 then
n1=val(text1)
else
n2=val(text1)
select case op
case 1
text1=n1+n2
case 2
text1=n1-n2
case 3
text1=n1*n2
case 4
if n2<>0 then text1=n1/n2
end select
op=0
end if
if index>0 then op=index
n1=val(text1)
newnum=true
end sub本回答被提问者采纳
第3个回答  2010-12-23
c的要不要