Reputation: 127
I have a array containing up to 10 values. I have 10 labels (label1, label2 ... so on to 10) I wantto use the array value to get a label. How do i get "label(arrayvalue).visiable = true
Im thinking about something like this
bokstavValue = Array.IndexOf(bokstav, TextBox1.Text)
label(bokstavValue).Visible= True
Upvotes: 0
Views: 803
Reputation: 177
It would be more along the lines of Me.Controls("labelName").Visible
as long as it is not embedded in a groupbox or panel or tab. That woulb be to change the actual control on the form
Upvotes: 2
Reputation: 67
Not sure if VBA, but for getting an array value, you have to give the index of the value you want, like:
aArray = Array(1,2,3,4) ''Returns a single dimension array of 4 elements, from index 0 to 3
Value = aArray (1) ''Returns 2
So, if you want to modify the visibility of a Label, calling it by its name, you can use:
aArray = Array("Label1","Label2") ''Returns a single dimension array of 2 elements, from index 0 to 1
Label(aArray(0)).Visible = True ''Turns on label "Label1"
Label(aArray(1)).Visible = True ''Turns on label "Label2"
Upvotes: 0