求VB编写特定的计算器

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:19:00
a=90 b=1~30 c=0.1~5 d=2
在Text1输入a
Text2输入b
Text3输入c
Text4输入d
点击Command1在Text5出现2个结果
出现的第一个结果=(a-b)+(c*d)
出现的第二个结果=(a-b)-(c*d)
点击Command2清除Text1.2.3.4.5上的数字
点击Command3退出程序
刚接触VB 希望能帮写出来 我会对照学习 先谢谢了
谢谢3楼的 不过运算最后的结果怎么能让他精确到小数点后一位
另外运算出来的结果怎么能不在一排显示 能分成2排

Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, d As Single
'(a-b)+(c*d)
'(a-b)-(c*d)
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
d = Val(Text4)
Text5 = Format((a - b) + (c * d), "0.0") & vbCrLf & _
Format((a - b) - (c * d), "0.0")
End Sub

Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Form_Load()
'a=90 b=1~30 c=0.1~5 d=2
Text1 = 90
Text2 = 20.5
Text3 = 3.2
Text4 = 2
'Text5.MultiLine = True '注意在属性中设置多行
Text5.Height = 500 '此句可省略
End Sub

点击Command1在Text5出现2个结果
出现的第一个结果=(a-b)+(c*d)
出现的第二个结果=(a-b)-(c*d)