set variable name to the value of an array

sarthemaker

Active member
Joined
Sep 4, 2009
Messages
36
Programming Experience
5-10
Is it possible to set the name of a variable to the value of an array? so I have the array:
num(0) = "one"
num(1) = "three"
num(2) = "twenty"

I was hoping that I could do something like this:

dim num(1) as integer = 3

Where it would set the variable three (the value of num(1)) to 3

but it doesn't seem to be working..
 
Actually I have found another way of doing this, where I use a with statement, and then set the buttons name within that.

VB.NET:
for i = 0 to 10 step 1
with new button
.name = "button" & i
end with
next

this makes 10 buttons all named button0,button1,button2,button...

But I have now run into another problem, I would also like to delete these buttons using a for loop, but I can't get each buttons name the same way.

VB.NET:
for i = 0 to 10 step 1
button.dispose
next

is there a way to add the value of `i` to the end of button in the above code?
 
The proper way to remove them is:
VB.NET:
Me.Controls.Remove(<button>)
Or from a container:
VB.NET:
Me.<containerName>.Controls.Remove(<button>)
I agree with kulrom, sometimes if you post a question with the intent and the desired outcome we can help you better.
 
Last edited:
Back
Top