Removing Labels previously created at run time

So I have created labels from controls in a timer. I would like to later, delete the labels once the data is refreshed

look up Close for a control

or just hide them


that way you can bring them back if you needed to

You need to keep a reference to each created label.

Instead of DIMing the new label, use for instance an array of labels as a property of the window or a dictionary, so you do

LabelsArray() as Label

Is a property of the window.

LabelsArray.append(New Label1) LabelsArray(LabelsArray.Ubound).Caption = "Clone" LabelsArray(LabelsArray.Ubound).Left = Me.Left + 10

(Code adapted from the LR)

You can then do something like: