很明显错误是inputbox=(a+b=,请输入答案)
inputbox不能做为变量的
你这是把inputbox当作变量用了
VB规定保留字不可以当变量来用
一楼的示例很好
是的
正确的代码为:
Dim
a
As
integer
Dim
b
As
integer
Dim
c
As
integer
a
=
Int(Rnd(10))
b
=
Int(Rnd(10))
c=inputbox("a+b=","请输入答案")
Private Sub Form_Click()
a = "请输入数据"
b = "数据计算"
'移到这里
Dim c As Integer, d As Variant, e As Variant, f As Variant
c = InputBox(a, b)
d = InputBox(a, b)
e = InputBox(a, b)
f = InputBox(a, b)
Print (c + d + e + f), (c + d + e + f) / 2
End Sub
Private Sub Command3_Click()
Dim c As Integer, d As Variant, e As Variant, f As Variant
a = "请输入数据"
b = "数据计算"
c = InputBox(a, b)
d = InputBox(a, b)
e = InputBox(a, b)
f = InputBox(a, b)
Print (c + d + e + f), (c + d + e + f) / 2
End Sub
把声明变量的句子放在上面,否则就是重复声明了!!