Mikerickson:
You mentionned in your previous post that I would have to adjust clsRTControls and clsRTControl for ComboBox. After looking at the code in the class I suppose I have to add the following to the classes:
clsRTControl:
Public WithEvents RTComboBox As MSForms.ComboBox
'...
Rem release variables
Set RTComboBox = Nothing
...
Rem events triggered by controls
'ComboBox section
Private Sub RTComboBox_Change()
Set RTParent.EventedRTControl = Me
RaiseEvent Change(RTControl)
End Sub
Private Sub RTComboBox_Click()
Set RTParent.EventedRTControl = Me
RaiseEvent Click(RTControl)
End Sub
Private Sub RTComboBox_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Set RTParent.EventedRTControl = Me
RaiseEvent DblClick(RTControl, Cancel)
End Sub
Private Sub RTComboBox_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Set RTParent.EventedRTControl = Me
RaiseEvent KeyDown(RTControl, KeyCode, Shift)
End Sub
Private Sub RTComboBox_KeyPress(ByVal keyAscii As MSForms.ReturnInteger)
Set RTParent.EventedRTControl = Me
RaiseEvent KeyPress(RTControl, keyAscii)
End Sub
Private Sub RTComboBox_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Set RTParent.EventedRTControl = Me
RaiseEvent MouseDown(RTControl, Button, Shift, x, y)
End Sub
Private Sub RTComboBox_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Set RTParent.EventedRTControl = Me
RaiseEvent MouseMove(RTControl, Button, Shift, x, y)
End Sub
Private Sub RTComboBox_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
Set RTParent.EventedRTControl = Me
RaiseEvent MouseUp(RTControl, Button, Shift, x, y)
End Sub
And for ClsRTControls add the case ComboBox in Select Case statement for each event and function:
Function Add(progID As Variant, Optional Name As String = "", Optional isVisible As Boolean = True) As MSForms.Control
Dim newControl As MSForms.Control
Dim newRTControl As ClsRTControl
If TypeName(progID) = "String" Then
If Name = vbNullString Then
Set newControl = Parent.Controls.Add(progID, Visible:=isVisible)
Else
Set newControl = Parent.Controls.Add(bstrProgid:=progID, Name:=Name, Visible:=isVisible)
End If
Else
Set newControl = progID
End If
If Not (newControl Is Nothing) Then
Set newRTControl = New ClsRTControl
With newRTControl
Set .RTParent = Me
Set .RTControl = newControl
Select Case TypeName(.RTControl)
Case "Label"
Set .RTLabel = newControl
Case "ComboBox"
Set .RTComboBox = newControl
Case "ListBox"
Set .RTListBox = newControl
Case "TextBox"
Set .RTTextBox = newControl
Case Else
Set newRTControl = Nothing
End Select
End With
'...
As for the code you posted in your post, I know it goes in the userform but it is still vague in my mind at what point the subs you added are called, for example the addOneBatch() should be triggered when the product ComboBox <> vbnullstring on the last added ComboBox only. Tried to check where this should be called and I think it would be called From ClsRTControls in the add function.
Once again thank you for your time