removing objects added by new

Hello,
the following code, out of a label called myLabel(0), creates three new labels

dim mm(0) as Label
myLabel(0).text = “A”

dim mSplit() as string = split(myString, “,”) //ex. B,C,D)
for i = 1 to mSplit.Ubound
mm.append new myLabel
//etc.
next

Later I need to remove/destroy the three labels created above, in order to create a new set of seven (or more or less) labels (ex. G,K,H,O,F,Y,U or “Z,S”).
But since myLabel.ubound or myLabel.remove dont exist, how to proceed?

BTW: I cannot set a fixed number of labels, since users will create their own sets of comma-delimited strings.

This should work:

mm( i ).Close
mm.Remove i

BTW, you are starting your mm array with one element at index 0 that will always be nil. Was that by design?

Sorry, I guess I’m not so good at explaining; what I have to remove are the myLabels objects I added in the loop.
since mm is “dimmed”, it goes out of scope after creating the several labels, yet the labels remain.

mm(0) refers to myLabel(0) object created in the IDE, necessary to make new objects using the new operator.

Make the array a property instead of a local variable?

[quote=239284:@Carlo Rubini]Sorry, I guess I’m not so good at explaining; what I have to remove are the myLabels objects I added in the loop.
since mm is “dimmed”, it goes out of scope after creating the several labels, yet the labels remain.

mm(0) refers to myLabel(0) object created in the IDE, necessary to make new objects using the new operator.[/quote]

What is mm ? Is it not an array ? If you make it a property of the window instead of Dimming it, you can then use it to close all new labels.

Yes, I got it.
mm now is a property whose ubound tells me how many myLabel had been added.

if mm.Ubound > 0 then
for i as Integer = mm.Ubound DownTo 1
myLabel(i).close
next
end if
redim mm(0)

In this way all the previously added myLabel disappear.
Thanks.