VB有三个复选框,任意选中两个后另一个变灰暗不能选
如图,我想选中任意两个复选框后,第三个变暗不能选,并且对应的text文本也随着check的选中可见或不可见...
如图,我想选中任意两个复选框后,第三个变暗不能选,并且对应的text文本也随着check的选中可见或不可见
展开
2个回答
展开全部
用循环判断.
你建立的3个复选框和3个text都建立成数组控件.才容易处理/
Private Sub Check1_Click(Index As Integer)
For i = 0 To 2
If Check1(i).Value = 1 Then
a = a + 1
If a = 2 Then
For x = 0 To 2
If Check1(x).Value <> 1 Then
Check1(x).Enabled = False
Text1(x).Enabled = False
End If
Next
End If
End If
If a < 2 Then
Check1(i).Enabled = True
Text1(i).Enabled = True
End If
Next
End Sub
附件里面是源码.
展开全部
Private Sub Check1_Click()
If Check1.Value <> 0 Then Text1.Visible = True
If Check2.Value <> 0 And Check1.Value <> 0 Then
Check3.Enabled = False
Text3.Enabled = False
End If
If Check3.Value <> 0 And Check1.Value <> 0 Then
Check2.Enabled = False
Text2.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check3.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Text3.Enabled = True
End If
End Sub
Private Sub Check2_Click()
If Check2.Value <> 0 Then Text2.Visible = True
If Check3.Value <> 0 And Check2.Value <> 0 Then
Check1.Enabled = False
Text1.Enabled = False
End If
If Check1.Value <> 0 And Check2.Value <> 0 Then
Check3.Enabled = False
Text3.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check3.Enabled = True
Text1.Enabled = True
Check1.Enabled = True
Text3.Enabled = True
End If
End Sub
Private Sub Check3_Click()
If Check3.Value <> 0 Then Text3.Visible = True
If Check3.Value <> 0 And Check1.Value <> 0 Then
Check2.Enabled = False
Text2.Enabled = False
End If
If Check3.Value <> 0 And Check2.Value <> 0 Then
Check1.Enabled = False
Text1.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check1.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Text1.Enabled = True
End If
End Sub
If Check1.Value <> 0 Then Text1.Visible = True
If Check2.Value <> 0 And Check1.Value <> 0 Then
Check3.Enabled = False
Text3.Enabled = False
End If
If Check3.Value <> 0 And Check1.Value <> 0 Then
Check2.Enabled = False
Text2.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check3.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Text3.Enabled = True
End If
End Sub
Private Sub Check2_Click()
If Check2.Value <> 0 Then Text2.Visible = True
If Check3.Value <> 0 And Check2.Value <> 0 Then
Check1.Enabled = False
Text1.Enabled = False
End If
If Check1.Value <> 0 And Check2.Value <> 0 Then
Check3.Enabled = False
Text3.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check3.Enabled = True
Text1.Enabled = True
Check1.Enabled = True
Text3.Enabled = True
End If
End Sub
Private Sub Check3_Click()
If Check3.Value <> 0 Then Text3.Visible = True
If Check3.Value <> 0 And Check1.Value <> 0 Then
Check2.Enabled = False
Text2.Enabled = False
End If
If Check3.Value <> 0 And Check2.Value <> 0 Then
Check1.Enabled = False
Text1.Enabled = False
End If
If Check2.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check3.Value = 0 Or Check1.Value = 0 And Check2.Value = 0 Then
Check1.Enabled = True
Text2.Enabled = True
Check2.Enabled = True
Text1.Enabled = True
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |