为用户表单上的控件检查多个Frame



我目前有一个代码,在用户表单上动态创建文本框。

在代码中,它检查表单上的单个框架中的控件,如果有控件被选中,则运行以下代码:

Function Addcheckboxes(emailtype)
Dim Ctrl As Control
Dim cont As Control
Dim i As Long
Dim h As Long
Dim intAppCount As Integer
Dim result As Long
' Loop through all the applications that have been selected with the email type and then create the appropriate email template on the userform lower box
If SpnColct.Count > 0 Then removeDynamicControls
For Each Ctrl In Me.Frame4.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl = True Then
Call AddTextBox(Mid(Ctrl.Name, 4), emailtype)
intAppCount = intAppCount + 1
End If

End If
Next
If intAppCount > 1 Then Me.Frame3.Caption = "Email Templates"
End Function

我如何展开它,使它同时检查用户表单上的第4帧和第5帧?

提前谢谢你

你可以像这样遍历每一帧…

Dim Frm As Variant
For Each Frm In Array(Me.Frame4, Me.Frame5)
For Each Ctrl In Frm.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
If Ctrl = True Then
Call AddTextbox(Mid(Ctrl.Name, 4), emailtype)
intAppCount = intAppCount + 1
End If

End If
Next
Next Frm

最新更新