vb四则运算计算机,怎么用VB做简易的四则运算计算器

您所在的位置:网站首页 vb计算器编程 vb四则运算计算机,怎么用VB做简易的四则运算计算器

vb四则运算计算机,怎么用VB做简易的四则运算计算器

2024-06-10 20:15| 来源: 网络整理| 查看: 265

很简单的:窗口放入四个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

取消

评论



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3