excel vba 编程教程如何实现取消多个复选框的勾选 5
展开全部
以下代码循环当前窗体上的所有控件,如果存在复选框控件,则将控件状态取反。希望对你有帮助
Dim nControl as Control
For Each nControl In Me.Controls
If TypeName(nControl ) = "CheckBox" Then
nControl .Value = Not nControl .Value
End If
Next
再给你段代码,按控件名设置状态(将CheckBox1等换成你的控件名):
Dim ctlArray as Variant
Dim i As Integer
ctlArray = Array("CheckBox1", "CheckBox2", "CheckBox3")
For i = 0 To Ubound(ctlArray)
Me.Controls(ctlArray(i)).Value = Not Me.Controls(ctlArray(i)).Value
Next i
Dim nControl as Control
For Each nControl In Me.Controls
If TypeName(nControl ) = "CheckBox" Then
nControl .Value = Not nControl .Value
End If
Next
再给你段代码,按控件名设置状态(将CheckBox1等换成你的控件名):
Dim ctlArray as Variant
Dim i As Integer
ctlArray = Array("CheckBox1", "CheckBox2", "CheckBox3")
For i = 0 To Ubound(ctlArray)
Me.Controls(ctlArray(i)).Value = Not Me.Controls(ctlArray(i)).Value
Next i
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询