Board index » Visual Studio » Strange one

Strange one

Visual Studio287
Any ideas why this is causing an "Out of stack space"? (I've used almost the

identical code in several programs without problems).



Private Sub chkPass_Click()

If chkPass.Value = vbChecked Then

lblPass.Enabled = False

chkPass.Value = vbUnchecked

ElseIf chkPass.Value = vbUnchecked Then

lblPass.Enabled = True

chkPass.Value = vbChecked

End If

End Sub



--

Regards



Steven Burn

Ur I.T. Mate Group CEO

www.it-mate.co.uk


-
 

Re:Strange one

yep, I've even tried several different methods.



The part it's giving the stack error on is;



chkPass.Value = vbUnchecked 'value = 0



--

Regards



Steven Burn

Ur I.T. Mate Group CEO

www.it-mate.co.uk

Larry Serflaten <serflaten@usinternet.com>wrote in message

Quote
"Steven Burn" <ceo@it-mate.co.uk>wrote



>Any ideas why this is causing an "Out of stack space"? (I've used almost

the

>identical code in several programs without problems).

>

>Private Sub chkPass_Click()

>If chkPass.Value = vbChecked Then

>lblPass.Enabled = False

>chkPass.Value = vbUnchecked

>ElseIf chkPass.Value = vbUnchecked Then

>lblPass.Enabled = True

>chkPass.Value = vbChecked

>End If

>End Sub





Have you stepped through the code yet, to see what the values are

as you step through?



LFS











-

Re:Strange one

"Steven Burn" <ceo@it-mate.co.uk>wrote

Quote
>Have you stepped through the code yet, to see what the values are

>as you step through?



yep, I've even tried several different methods.



I have a hard time believeing you stepped through the procedure.

You have set up a recursive event. The user clicks on the checkbox

so that fires the event:



Private Sub chkPass_Click()

If chkPass.Value = vbChecked Then

lblPass.Enabled = False

chkPass.Value = vbUnchecked

ElseIf chkPass.Value = vbUnchecked Then

lblPass.Enabled = True

chkPass.Value = vbChecked

End If

End Sub



The box is checked, which goes through the IF part, when it

sets the value to vbUnchecked, that will fire the event again,

this time the box is unchecked. So, when it get to the Else

part and finds it unchecked, that part set it back to checked

which will fire the event again, this time the box is checked,

and so on, and so on....



You never get to End Sub, so how could you say you stepped

through the code?



LFS











-

Re:Strange one

What I meant was, I've been looking at it for the past hour or so (I thought

thats what you meant).



Basically, all it is meant to do is, if the checkbox is checked, uncheck it

and disable the label.... and vica versa.



I'll try sticking an exit sub in there and see if that works....



Thanks for the reply (I'm half asleep here)...



--

Regards



Steven Burn

Ur I.T. Mate Group CEO

www.it-mate.co.uk

Larry Serflaten <serflaten@usinternet.com>wrote in message

Quote
"Steven Burn" <ceo@it-mate.co.uk>wrote

>>Have you stepped through the code yet, to see what the values are

>>as you step through?



>yep, I've even tried several different methods.



I have a hard time believeing you stepped through the procedure.

You have set up a recursive event. The user clicks on the checkbox

so that fires the event:



Private Sub chkPass_Click()

If chkPass.Value = vbChecked Then

lblPass.Enabled = False

chkPass.Value = vbUnchecked

ElseIf chkPass.Value = vbUnchecked Then

lblPass.Enabled = True

chkPass.Value = vbChecked

End If

End Sub



The box is checked, which goes through the IF part, when it

sets the value to vbUnchecked, that will fire the event again,

this time the box is unchecked. So, when it get to the Else

part and finds it unchecked, that part set it back to checked

which will fire the event again, this time the box is checked,

and so on, and so on....



You never get to End Sub, so how could you say you stepped

through the code?



LFS















-

Re:Strange one

I've just found the cause....and boy do I feel like an edgit now... all I

had to do was remove the chkpass = unchecked etc after checking it's value.



Sorry for wasting people's time........



I seriously think it is time I got some sleep...... or atleast a triple

espresso...



--

Regards



Steven Burn

Ur I.T. Mate Group CEO

www.it-mate.co.uk

Larry Serflaten <serflaten@usinternet.com>wrote in message

Quote
"Steven Burn" <ceo@it-mate.co.uk>wrote

>>Have you stepped through the code yet, to see what the values are

>>as you step through?



>yep, I've even tried several different methods.



I have a hard time believeing you stepped through the procedure.

You have set up a recursive event. The user clicks on the checkbox

so that fires the event:



Private Sub chkPass_Click()

If chkPass.Value = vbChecked Then

lblPass.Enabled = False

chkPass.Value = vbUnchecked

ElseIf chkPass.Value = vbUnchecked Then

lblPass.Enabled = True

chkPass.Value = vbChecked

End If

End Sub



The box is checked, which goes through the IF part, when it

sets the value to vbUnchecked, that will fire the event again,

this time the box is unchecked. So, when it get to the Else

part and finds it unchecked, that part set it back to checked

which will fire the event again, this time the box is checked,

and so on, and so on....



You never get to End Sub, so how could you say you stepped

through the code?



LFS















-

Re:Strange one



"Steven Burn" <ceo@it-mate.co.uk>wrote in message



Quote
I've just found the cause....and boy do I feel like an edgit now... all I

had to do was remove the chkpass = unchecked etc after checking it's

value.



But do you understand WHY it was happening?





-

Re:Strange one

I certainly do....... the way I had it, it was going in a never ending loop



--

Regards



Steven Burn

Ur I.T. Mate Group CEO

www.it-mate.co.uk

Jeff Johnson [MVP: VB] <i.get@enough.spam>wrote in message

Quote


"Steven Burn" <ceo@it-mate.co.uk>wrote in message

news:#QAjfCkXDHA.3924@tk2msftngp13.phx.gbl...



>I've just found the cause....and boy do I feel like an edgit now... all

I

>had to do was remove the chkpass = unchecked etc after checking it's

value.



But do you understand WHY it was happening?









-