Board logo

标题: [基础] VB里面简单计算机代码有什么错误 [打印本页]

作者: jeremiah    时间: 2009-10-13 12:32     标题: VB里面简单计算机代码有什么错误

Private Sub Command1_Click()
opt = "+"
End Sub

Private Sub Command2_Click()
opt = "-"
End Sub

Private Sub Command3_Click()
opt = "*"
End Sub

Private Sub Command4_Click()
opt = "/"
End Sub

Private Sub Command5_Click()
Dim a, b, result As Double
a = Text1.Text
b = Text2.Text
Select Case opt
Case "+"
result = Val(a) + Val(b)
Case "-"
result = Val(a) - Val(b)
Case "*"
result = Val(a) * Val(b)
Case "/"
result = Val(a) / Val(b)
End Select
Text3.Text = result
End Sub

Private Sub Text1_Change()

End Sub

Private Sub Text2_Change()

End Sub

Private Sub Text3_Change()

End Sub

为什么第三个text里面的值总是0,向高手请教
作者: Nothing    时间: 2009-10-13 23:44

opt需在定义成公共变量
作者: jeremiah    时间: 2009-10-17 10:24

谢谢,我是新手,对不起提这么弱智的问题
作者: Nothing    时间: 2009-10-18 10:34






欢迎光临 编程开发论坛 (http://bbs.lihuasoft.net/) Powered by Discuz! 6.0.0