For ag = 0 To 4 Step 1
aaaarray(ag).Clear
aaaarray(ag).AddItem "a"
aaaarray(ag).AddItem "b"
aaaarray(ag).AddItem "c"
aaaarray(ag).AddItem "d"
Set ComboClass(ag).ComboBoxArray = Userform1.Controls("ComboBox" & ag + 1)
Set TextClass(ag).TextBoxArray = Userform1.Controls("TextBox" & ag + 1)
Set CheckClass(ag).CheckBoxArray = Userform1.Controls("CheckBox" & ag + 1)
Next ag
End Sub
==> Class1 程式段 ::
Option Explicit
Public WithEvents ComboBoxArray As MSForms.ComboBox
Public WithEvents TextBoxArray As MSForms.TextBox
Public WithEvents CheckBoxArray As MSForms.CheckBox
Public Sub ComboBoxArray_Change()
MsgBox ComboBoxArray.Name
End Sub
Public Sub TextBoxArray_Click()
MsgBox TextBoxArray.Name
End Sub