RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
I have a series of labels on one userform and a series commandbuttons on another userform. They both contain properties that I want to access through a Class Module (see below). At the moment I have to apply them to two separate class modules (i.e. one for labels and one for command buttons) - is there a way to combine them?
Class module for label
Class module for CommandButton
Class module for label
VBA Code:
Option Explicit
Public WithEvents ElementButtonGroup As MSForms.Label
Private mfrmParent As Object
'--public properties
Public Property Set Parent(frmParent As Object)
Set mfrmParent = frmParent
End Property
'--event procedures
Private Sub ElementButtonGroup_Click()
mfrmParent.SelectedElement = ElementButtonGroup.Caption
mfrmParent.ElementLabel = ElementButtonGroup.Name
mfrmParent.ElementSet
End Sub
Class module for CommandButton
VBA Code:
Option Explicit
Public WithEvents ElementChoiceGroup As MSForms.CommandButton
Private mfrmParent As Object
'--public properties
Public Property Set Parent(frmParent As Object)
Set mfrmParent = frmParent
End Property
'--event procedures
Private Sub ElementChoiceGroup_Click()
mfrmParent.SelectedElement = ElementChoiceGroup.Caption
mfrmParent.ElementLabel = ElementChoiceGroup.Name
mfrmParent.ElementSet
End Sub