So i have a class that creates a new label and textbox when it is called. The names of each label and textbox are in a continues order counting upward using a variable called i:
"Label" & icreates the name Label1 and"Textbox" & icreates the name Textbox1i += 1
And so on. Now i want to add a procedure that deletes the last label and textbox using i. I have tried to make this procedure using the lines of code below but this doesnt work as the string cannot be converted to system.windows.forms.control :
Form1.Controls.Remove("Label" & i)
Form1.Controls.Remove("Textbox" & i)
i -= 1
Controls is a list of controls using the line of code:
Public controls As List(Of Control)
Basically i need a way to delete a label and textbox using the variable i in the class. Any ideas? Thanks.