Good point, but at this point, my sole aim is to learn how to pass different count of the same type of controls to a class and make them all behave the same
If you look at these three approaches they are all slightly different versions of the same general techniques. Each version is slightly more encapsulated and as
@Josef P. states this is good.
A few more classes can certainly achieve a better separation of responsibilities and if a few generally usable classes are then created, I even see this as an advantage.
1. All three approaches have a composition class that holds the labels and basically extends the properties of that label and captures the label events. In other languages that really supported OOP you would not do this. You would create a class (in my case SortableLabel) that inherits a Label and truly extends the methods and properties of a label. However VBA does not support inheritance so you have to build a composite class that has a label as a class property and uses with events.
2. All approaches then have a class that holds the instances of the class. I call this a collection class.
3. All approaches trap the label event of the instances held in the collection and then call a procedure that raises a common event that can be trapped somewhere else.
If you look at what
@arnelgp did this is a more fundamentally correct version of what I did. He created a Listener Class / Notifier class where the instances call an procedure that raises the event then you only have to listen to a single event raised by the notifier / listener class. As I said my approach seems a little quirky in that the collection class is also the notifier. This means the label instances have to know about their own collection as they are created. It works but not fundamentally correct IMO.
So bottom line, it is some modified version of this.
1. Create your "label" class that brings in the label using withevents to trap its events. Create all the additional properties. This class knows nothing of other custom labels and does not do any of the processing of the filtering and property setting.
2. Create some kind of a collection class to hold your custom labels.
3. Create some kind of listener that your custom labels call a method to then raise a single custom method.
In my case I did not really raise another event, but did the processing directly in the collection class.
4. Have the collection class do the processing.