测试效果:
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
程序代码:
Dim a As Integer '判断复选框个数
Dim b As Integer '判断单选框个数
Dim x As Integer '用于循环显示选项
Private Sub Check1_Click(Index As Integer)
If Check1.Item(Index).Value = 1 Then '如果是勾选
If a < b Then '如果同时在设置数量范围内
a = a + 1 '记录选择个数
Else
Check1.Item(Index).Value = 0 '如果在范围外,则不选择
a = a + 1
End If
ElseIf Check1.Item(Index).Value = 0 Then '如果是取消勾选
a = a - 1 '记录选择个数
End If
Text1.Text = "" '清空文本框,以用来重新显示选择项
For x = 0 To 5
If Check1.Item(x).Value = 1 Then
Text1.Text = Text1.Text & " " & Check1.Item(x).Caption
End If
Next x
End Sub
Private Sub Form_Load()
Dim i As Integer
a = 0
b = 1
End Sub
Private Sub Option1_Click(Index As Integer) '每次选择,清空以前选项
b = Index + 1
For i = 0 To 5
Check1.Item(i).Value = 0
Next i
a = 0 '同时清空记录数
End Sub