用VB做一个能进行加减乘除的运算器,界面如图所示,把代码写出来给我就好了,我计算机太烂了,

问题描述:

用VB做一个能进行加减乘除的运算器,界面如图所示,把代码写出来给我就好了,我计算机太烂了,
1个回答 分类:综合 2014-12-04

问题解答:

我来补答
Private Sub Command1_Click() '计算
Select Case Text2
Case "+"
Text4 = Val(Text1) + Val(Text3)
Case "-"
Text4 = Val(Text1) - Val(Text3)
Case "*"
Text4 = Val(Text1) * Val(Text3)
Case "/"
If Val(Text3) = 0 Then
Text4 = "除数不能为零!"
Else
Text4 = Val(Text1) / Val(Text2)
End If
End Select
End Sub
Private Sub Command2_Click() '清除
Text1 = "" '第1个操作数
Text2 = "" '运算符
Text3 = "" '第2个操作数
Text4 = "" '结果
End Sub
Private Sub Command3_Click() '退出
Unload Me
End Sub
再问: 我试了一下,除法不行
再答: 除数写错了,是Text3 Private Sub Command1_Click() '计算 Select Case Text2 Case "+" Text4 = Val(Text1) + Val(Text3) Case "-" Text4 = Val(Text1) - Val(Text3) Case "*" Text4 = Val(Text1) * Val(Text3) Case "/" If Val(Text3) = 0 Then Text4 = "除数不能为零!" Else Text4 = Val(Text1) / Val(Text3) End If End Select End Sub Private Sub Command2_Click() '清除 Text1 = "" '第1个操作数 Text2 = "" '运算符 Text3 = "" '第2个操作数 Text4 = "" '结果 End Sub
 
 
展开全文阅读
剩余:2000
下一页:明矾净水