作业帮 > 综合 > 作业

vb 复选框用Check1.Value = Checked的时候就自动运行了Check1_Click.怎么办?

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/17 23:57:31
vb 复选框用Check1.Value = Checked的时候就自动运行了Check1_Click.怎么办?
程序如图
代码如下:
Private Sub Check1_Click()
If Check1.Value = 1 Then
For i = 0 To 39
Check2(i).Value = 1
Next i
ElseIf Check1.Value = 0 Then
For i = 0 To 39
Check2(i).Value = 0
Next i
End If
End Sub
Private Sub Check2_Click(Index As Integer)
Dim Check2ValueChecked,Check2ValueUnchecked As Boolean
Check2ValueChecked = False
Check2ValueUnchecked = False
For i = 0 To 39
If Check2(i).Value = 1 Then
Check2ValueChecked = True
Else
Check2ValueUnchecked = True
End If
Next i
If Check2ValueChecked = True And Check2ValueUnchecked = True Then
Check1.Value = 1
ElseIf Check2ValueChecked = True Or Check2ValueUnchecked = True Then
Check1.Value = 2
Else
Check1.Value = 0
End If
Check2ValueChecked = False
Check2ValueUnchecked = False
End Sub
帮我简化并解决一下吧,我希望check1与check2()共同被选或无选,或check2部分被选时check1.value=2
vb 复选框用Check1.Value = Checked的时候就自动运行了Check1_Click.怎么办?
先解决你的问题:
checkbox在设计时设置其value就不会引发click事件,但如果用代码的话就会引发click事件.
另外你的程序把简单的问题复杂化了,也许是我看得不仔细.