这是我在vba模块中的代码,只需一行就可以将属性设置为多个控件:
' General Declaration
Public Enum con1_enumLetAction
cEnabled
cDisabled
cVisible
cUnVisible
End Enum
' Public function in the same module
Public Function Con_LetArray(LetAction As con1_enumLetAction, ByRef TheArray As Variant)
Dim i As Integer
Dim conControl As Control
For i = LBound(TheArray) To UBound(TheArray)
Set conControl = TheArray(i)
Select Case LetAction
Case cEnabled
conControl.Enabled = True
Case cDisabled
conControl.Enabled = False
Case cVisible
conControl.Visible = True
Case cUnVisible
conControl.Visible = False
End Select
Next
End Function
我在包含4个选项按钮和命令按钮
的表单中使用了此功能Private Sub CommandButton1_Click()
mcon1_.Con_LetArray cDisabled, Array(OptionButton1, OptionButton2, OptionButton3)
End Sub
问题是什么?错误"变量未定义"和OptionButton2高亮显示