'以下是一段代码,希望对窗体中24个checkbox进行赋值。由于checkbox2、checkbox22、checkbox23与其它checkbox的值是排异的,也就是说当checkbox2、checkbox22、checkbox23分别选中时其它各个就为非选中状态。
'为什么当在这三个checkbox2、checkbox22、checkbox23中相互点击时会出现死循环?
'按CTRL+BREAK可中断,跟踪发现只在第10至第50条语句之间(或者是80-120)重复执行,60语句却不执行。晕啊!
10 Private Sub CheckBox22_Click()
20 For i = 1 To 24
30 Controls("checkbox" & i).Value = 0
40 Next
50 CheckBox22.Value = 1
60 TextBox2.Text = CheckBox22.Caption
70 End Sub
80 Private Sub CheckBox23_Click()
90 For i = 1 To 24
100 Controls("checkbox" & i).Value = 0
110 Next
120 CheckBox23.Value = 1
130 TextBox2.Text = CheckBox23.Caption
140 End Sub
150 Private Sub CheckBox2_Click()
160 For i = 1 To 24
170 Controls("checkbox" & i).Value = 0
180 Next
190 CheckBox2.Value = 1
200 TextBox2.Text = CheckBox2.Caption
210 End Sub
10 Private Sub CheckBox22_Click()
20 For i = 1 To 24
30 Controls("checkbox" & i).Value = 0
40 Next
50 CheckBox22.Value = 1
60 TextBox2.Text = CheckBox22.Caption
70 End Sub