In VB6 this would be possible by setting up the label control as an array of labels (ie. lblTest(0), lblTest(1), lblTest(2), etc)
Unfortunately VBA doesn't support control arrays. To achieve this you'll need to use a technique whereby you sink in to a special contain class the control you have just created.
In other words, create a custom "label" class, one that exposes the Label object's events which you would like to capture (as well as any other properties). Create a new instance of the class for each label you create at runtime, and pass in a pointer to the new label control.
You then will probably want to create a collection class to contain each instance of your custom label class. This will allow you to iterate over the new set of objects more easily.
If none of this makes immediate sense to you, try searching google with something like "control arrays vba" and you should eventually find some examples of the technique
|