这个vb程序为什么报错

来源:百度知道 编辑:UC知道 时间:2024/06/26 01:29:08
Private Sub Form_Activate()
Dim x As Integer, y As Integer
x = InputBox("")
If x < 1000 Then y = x
ElseIf x < 2000 And x >= 1000 Then y = 0.9 * x
ElseIf x < 3000 And x >= 2000 Then y = 0.8 * x
Else y=0.7*x
End If
Print x; " "; y
End Sub

Private Sub Form_Activate()
Dim x As Integer, y As Integer
x = InputBox("")
ElseIf x < 2000 And x >= 1000 Then y = 0.9 * x
ElseIf x < 3000 And x >= 2000 Then y = 0.8 * x
Else: y = 0.7 * x
End If
Print x; " "; y
End Sub
就可以了!
主要是要把If x < 1000 Then 和 y = x写成两行!
原因请参考:http://zhidao.baidu.com/question/89793134.html 以及我在
http://zhidao.baidu.com/question/89303782.html 中的回答。

Private Sub Form_Activate()
Dim x As Integer, y As Integer
x = InputBox("")
If x < 1000 Then
y = x
ElseIf x < 2000 And x >= 1000 Then
y = 0.9 * x
ElseIf x < 3000 And x >= 2000 Then
y = 0.8 * x
Else: y = 0.7 * x
End If
Print x; " "; y