我试图在用户窗体上遍历两组控件。如果两个控件(togglebuttons)的组合为真,那么就做一些事情。从创建控件的userform调用sub。这是我第一次使用userform控件变量,下面的代码不会编译,所以这可能是完全错误的。有什么建议吗?
更新了代码示例,但是我收到了编译错误。见下图:
Private Sub CONTROLS_Click()
Dim X As Integer, Y As Integer
Dim BOOK As Variant, STRAT As Variant
BOOK = Array("TYPE1", "TYPE2")
STRAT = Array("FAST", "MEDIUM", "SLOW")
For X = LBound(BOOK) To UBound(BOOK)
If Me.CONTROLS(BOOK(X)).Value = True Then
For Y = LBound(STRAT) To UBound(STRAT)
If Me.CONTROLS(STRAT(Y)).Value = True Then
'DO SOMETHING
End If
Next Y
End If
Next X
End Sub