What's happening is that setting a check box's value fires the Click event.
Thus, in the clickevent of a checkbox, setting it's value to some other
value (or, in the case below, in a control array and setting another control
element's value) causes a recursive call to the click event (which is why
you get a "Out of Stack Space" error).
To fix the problem, all you need is a static boolean (or int, if earlier
then v. 4) that keeps track of whether you are in a recursive call or not.
If you are, then don't do any code, just pop on out:
---In the Click event:
Static bAlreadyHere as boolean
if not bAlreadyHere then
bAlreadyHere = true
'Do your setting of the checkboxes now
bAlreadyHere = false
end if
This way, whenever the code gets recursively called, your static value will
be set to true, so you wont go into the code that sets the checkbox's
values, staving off another round of recursion. Once you are done setting
the values of the checkboxes, you will set your variable back to false, so
that a normal "real" click will cause the proper action to take place.
--Tristan
Quote:
>I have several Check boxes in an array, grouped in three's. What I want
>to do is if you check say Check1(0) then Check(1) and Check(2) will
>automatically be unchecked if already checked. This is what I have tried
>in the CLICK event the DOES NOT WORK. It gives an "Out of Stack Space"
>when you click on one of the three....
>Private Sub Check1_Click(Index As Integer)
>Select Case Index
> Case Is = 0
> Check1(0).Value = 1
> Check1(1).Value = 0
> Check1(2).Value = 0
> Case Is = 1
> Check1(1).Value = 1
> Check1(0).Value = 0
> Check1(2).Value = 0
> Case Is = 2
> Check1(2).Value = 1
> Check1(0).Value = 0
> Check1(1).Value = 0
>End Select
>End Sub
>Is there any way else to do what I want to do with this????
>Thanks in advance....
>Kenny