凤凰卫视股东:VB操作出问题了,跪求大家过来看看,谢谢!

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 18:09:57
我做了一个选择评分系统,每题4个选项一个对的。语句是这样的:
Option Explicit
Dim a As Integer

Private Sub Option1_Click()
a = a + 10
End Sub

Private Sub Option5_Click()
a = a + 10
End Sub

Private Sub Option9_Click()
a = a + 10
End Sub
……
End Sub
Text1.Text = a

还有一种方案:

Private Sub Command1_Click()
If Option4.Value = True Then
a = a + 10
End If
If Option12.Value = True Then
a = a + 10
……
End If
Text1.Text = a

可这两种方案做有个漏洞,在测试时如果选了正确选项再改选错误的,这样也会加10,如果再改,然后又改回正确的,又加10……
而且还有一点,如果执行unload me命令,再打开该窗口,再选一个正确选项,又在原有基础上加10
这是严重的错误啊!我错在了哪?怎么修改?

Private Sub Command1_Click()
If Option1.Value = True Then
a = 11
End If
If Option2.Value = True Then
a = -3
End If
If Option3.Value = True Then
a = 0
End If
If Option4.Value = True Then
a = 3
End If
If Option5.Value = True Then
b = 4
End If
If Option6.Value = True Then
b = 11
End If
If Option7.Value = True Then
b = 0
End If
If Option8.Value = True Then
b = -1
End If
If Option9.Value = True Then
c = 0
End If
If Option10.Value = True Then
c = 11
End If
……
这样就行了

看不懂,抱歉!

你这个程序本来就是错的 哦