Maybe you want it to work with the first option selected or not, if so you can save its state before in a boolean variable and then update its state at the end, using that variable.
hmmm. I think I haven't stated my problem here properly. The code I posted is a sample. But in my project I will create n number of controls at any time. and I do not know which control is selected.
Any way I got an idea. so, I will be going through all controls to make sure which one is selected and then load additional control and check the selected control again.
You can use an Integer and Option1_Click event. Since Option1 is a control array, you will get "Index" when one of theme is clicked. Here's what i'm talking about:
VB Code:
Option Explicit
[B]Private selected As Integer[/B]
Private Sub Command1_Click()
Dim I As Integer
For I = 1 To 3
Load Option1(I)
With Option1(I)
.Left = Option1(I - 1).Left
.Top = Option1(I - 1).Top + 357
.Value = False
.Visible = True
End With
Next I
Option1([B]selected[/B]).Value = True
End Sub
Private Sub Option1_Click([B]Index[/B] As Integer)
The problem is the first created instance inherits the Value property of index 0 instance, which is True, so it becomes the selected option until .Value = False line in with structure is reached. At which point both option buttons have value = false. 2nd and 3rd option buttons then inherit instance index 0 value property of false.
You don't have to iterate through the entire control array... just save the value property of instance at index 0 and reset it after loading new instances like what jcis did