我正在尝试创建一个通用过程,只需使用您可以看到的参数调用此过程,即可将“X”控件对象的可见属性更改为“False/True”:
' Desired usage:
' Disable_Controls(CheckBox, Me.Panel1.Controls, False)
Public Sub Disable_Controls(ByVal ControlType As Control, _
ByVal Container As ControlCollection, _
ByVal Visible As Boolean)
For Each Control As Control In Container
' If TypeOf Control Is CheckBox then...
If TypeOf Control Is Control Then
Control.Visible = Visible
End If
Next
End Sub
问题是我无法像尝试那样传递控件名称(“Checkbox”),我已经尝试使用“CType(Control,CheckBox)”但没有奏效。
我怎么能这样做?