赋值问题

来源:百度知道 编辑:UC知道 时间:2024/06/21 20:21:45
Private Sub Command1_Click()
Dim t1 As Integer
Dim t2 As Integer
Dim t3 As Integer
Dim t4 As Integer
Dim t5 As Integer
Dim t6 As Integer
Dim t7 As Integer
Dim t8 As Integer
Dim zongfen As Integer

Let zongfen = Val(t1) + Val(t2) + Val(t3) + Val(t4) + Val(t5) + Val(t6) + Val(t7) + Val(t8) + Val(t9) + Val(t10)
Print "总分 "; zongfen;
End Sub

Private Sub Option2_Click()
Let t1 = 0
End Sub

Private Sub Option3_Click()
Let t1 = 5
End Sub

Private Sub Option4_Click()
Let t1 = 0
End Sub

Private Sub Option5_Click()
Let t1 = 0
End Sub
现在的情况是不管选哪个都和都得0
我的意思就是选option4的时候想把t1赋值为5,其他时候为0请问上面哪里可以改一改?

你要设置全局变量啊..
在所有过程外面定义

private t1 as integer

Private Sub Command1_Click()
Dim t2 As Integer
Dim t3 As Integer
Dim t4 As Integer
Dim t5 As Integer
Dim t6 As Integer
Dim t7 As Integer
Dim t8 As Integer
Dim zongfen As Integer
....省略

你也可以在函数里面判断哪个option被选中

if Option2.Value = True
Let t1 = 0
elseif Option3.Value = True
Let t1 = 5
....省略