4个回答
展开全部
很简单的:窗口放入四个COMMAND控件(Caption属性分别为+、-、X、÷),三个TEXT控件,再放入三个Label控件(Caption属性分别为:操作数1、操作数2和计算结果),窗口的Caption属性改为“四则运算”
代码如下:
Private Sub Command1_Click()
If Val(Text1.Text) + Val(Text2.Text) <> Int(Val(Text1.Text) + Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) + Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Command2_Click()
If Val(Text1.Text) - Val(Text2.Text) <> Int(Val(Text1.Text) - Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) - Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End If
End Sub
Private Sub Command3_Click()
If Val(Text1.Text) * Val(Text2.Text) <> Int(Val(Text1.Text) * Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) * Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Command4_Click()
If Val(Text1.Text) / Val(Text2.Text) <> Int(Val(Text1.Text) / Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) / Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub
代码如下:
Private Sub Command1_Click()
If Val(Text1.Text) + Val(Text2.Text) <> Int(Val(Text1.Text) + Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) + Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Command2_Click()
If Val(Text1.Text) - Val(Text2.Text) <> Int(Val(Text1.Text) - Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) - Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End If
End Sub
Private Sub Command3_Click()
If Val(Text1.Text) * Val(Text2.Text) <> Int(Val(Text1.Text) * Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) * Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Command4_Click()
If Val(Text1.Text) / Val(Text2.Text) <> Int(Val(Text1.Text) / Val(Text2.Text)) Then
Text3.Text = Format(Val(Text1.Text) / Val(Text2.Text), "0.######")
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个怎么样?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim a as integer
dim b as integer
a=text1.text
b=text2.text
Private Sub Command1_Click()
text3.text=val(a+b)
end sub
Private Sub Command2_Click()
text3.text=val(a-b)
end sub
Private Sub Command3_Click()
text3.text=val(a*b)
end sub
Private Sub Command4_Click()
text3.text=val(a/b)
end sub
dim b as integer
a=text1.text
b=text2.text
Private Sub Command1_Click()
text3.text=val(a+b)
end sub
Private Sub Command2_Click()
text3.text=val(a-b)
end sub
Private Sub Command3_Click()
text3.text=val(a*b)
end sub
Private Sub Command4_Click()
text3.text=val(a/b)
end sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询