Suppose I have a form with many controls, but at the beginning a lot of them are hidden and only become visible if the user interactive choices go that way.
With this application I need to take the user input, do a bit of crunching and get a result. The result gives me an integer where the integer is the number of (lets say) a Picturebox control that I now want to make visible. My problem is that I can't seem to find an easy way to reference that Picturebox control using the name of the variable that contains my integer.
Suppose I have three Picturebox controls. Each of them is .Visible = 0
Now I do:-
$i = get-random (1,2,3) # $i is the number of the Picturebox I want to make .Visible = 1
$picturebox$i.Visible = 1
($picturebox)$i.Visible = 1
$($picturebox$i).Visible = 1
$picturebox$($i).Visible = 1
Even $a = $picturebox & "$i"
All crash out.
See what I mean?
Would appreciate any suggestions.
$script:pictureBoxes = $pictureBox1, $pictureBox2, etc.
Then reference the array to make them visible.
$script:pictureBoxes[$i].Visible = $true
SAPIEN Technologies, Inc.
Who is online
Users browsing this forum: No registered users and 4 guests