求用vb编写一个简易计算器的程序代码
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
界面:
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
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
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
c的要不要
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询