Hi,
there are different ways to solve this Problem. I prefer the following :
- You have a collection for the elements which should be variable created.
- You build a SUB Create_Elements and a SUB Dispose_Elements
- When you Change the property of your Control which defines the number a elements you also run the SUB Dispose_Elemets and after this the SUB Create_Elements
- inside the SUB Create_Elements you have the following Code :
<pre lang="vb">
for i as integer = 1 to _Number_Elements
Dim myControl as new Button
myControl.parent = Me
myCollection.add(myControl)
next
in the Sub Dispose_Elements your run through your Collection to dispose the elemets inside.
If would suggest that you first try to build up my Suggestion.
After that (with seeing your code) we could complete it ...
greetings
Ralf