做VB的题 悬赏积分20

来源:百度知道 编辑:UC知道 时间:2024/06/23 20:58:38
编一模拟袖珍计算器的完整程序。要求:输入两个操作数和一个操作字符。根据操作符决定所做的运算。
提示:1,为了使程序运行正确,对存放操作符的文本框Text3,应使用Trim函数,去除运算符两边的空格。
2,对于存放操作符的文本框Text3,利用Select Case语句实现相应的运算。(要求代码完整)

Private Sub Command1_Click()
Dim fx As String
fx = Trim(Text3)
Select Case fx
Case "+":
re = Val(Text1) + Val(Text2)
Case "-":
re = Val(Text1) - Val(Text2)
Case "*":
re = Val(Text1) * Val(Text2)
Case "/":
re = Val(Text1) / Val(Text2)
Case "^"
re = Val(Text1) ^ Val(Text2)
End Select
Label1.Caption = "结果:" & re
End Sub

留下邮箱,发给你