hi all. i want to know what code to use to change the name of a field (of say a checkbox) if a condition is met while the program is running.
is it therefore possible to name 5 checkboxes: P1, P2, P3...P5, and then use a variable, (eg : choice) to assign functions to the fields. eg: P(choice).value = True
thank-you for your help.

Field names
Kvltv
Dim boxes As New List(Of Checkbox)
Private Sub MakeArray()
boxes.Add(check1)
boxes.Add(check2)
boxes.Add(check3)
...
End Sub
All you have to do then is call the MakeArray function in one of the loading routines and you should be set. You could also add more checkboxes to your array by simply creating the checkbox and adding it to the boxes list, just make sure you add it to the form's (or panel's or whatever container) Controls collection or it won't show up.
Aceofspades
Best regards.
Fernando Cardoso
IainMc
Hi George,
This sounds like a job for my old favourite, the Controls collection. This is a collection of all of the controls on the form.
If you have an array of checkboxes, say P1, P2, P3 ... you can address them, by name, in a variety of manners:
me.Controls("P1").value=true
me.Controls("P" &"2").value=true
Choice=3
me.Controls("P" & Choice).value=true
or whatever else you want to do with them.
I hope this gives you an idea or two.
Regards
Nigel
Srefae
i am using VB.Net 2005 with Natinal Instruments Measurement Studio; and i am having trouble creating an array of controls and then indexing through them. using your example i run into issues with the
dim x as new list(of NIcontrol)
the NIcontol is an un declared object and i have not been sucessful in geting this to work; any ideals
thenks
george