|
-
Oct 3rd, 2000, 08:00 AM
#1
Thread Starter
Frenzied Member
I found something interesting (well, for me)
Code:
Private Sub Check1_Click()
Dim ha As Boolean
ha = Check1.Value
Check1.Value = 1
Check1.Value = Not (Int(ha)) 'This generates an error after a few seconds (Out of stack space), I know what the error means, but why is it happening here?
End Sub
Please note that I don't need the code (ofcourse there are better ways ), I was just testing stuff, nothing important.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 3rd, 2000, 08:04 AM
#2
Fanatic Member
Maybe the click event fires when the value is changed.
-
Oct 3rd, 2000, 08:08 AM
#3
Fanatic Member
You are stuck in a loop!
When you get to the line Check1.Value = Not (Int(ha)), you are forced back to Private Sub Check1_Click(), and so on till out of stack space.
put a break on the line and step trough with F8...
-
Oct 3rd, 2000, 08:13 AM
#4
Lively Member
It will work if you put the code in MouseUp event instead...
D
-
Oct 3rd, 2000, 08:17 AM
#5
Thread Starter
Frenzied Member
Yeah mates, I all know I'm in a loop and stuff, that's what I wanted, but what's the stack and what's placed in it, the variable or the Check1.Value?
I knew you were about to react like this, that's why I wrote the please note under my post
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 3rd, 2000, 08:25 AM
#6
Fanatic Member
While in break mode to a Ctrl+L !!!!!!!!
no code supplied by reqest!!!!!!!
Read the VB help for the call stack.
-
Oct 3rd, 2000, 08:25 AM
#7
Fanatic Member
The stack is something like a temporary variable. You use it much in assembly.
If you need to do an api call in assembly, then you use the push mnemonic to set the "parameters" of the api function on the stack.
Everytime the event is fired, the old event, where it will go back to after finishing the code is putted on the stack.
If this will happen much, then the stack will become full.
Sorry if you don't get what I say, my English is not very good.
-
Oct 3rd, 2000, 08:36 AM
#8
Thread Starter
Frenzied Member
Thanx oetje, that helped...
I appreciate your attempt Jerry, but what are you trying to tell me?
While in break mode to a Ctrl+L !!!!!!!!
no code supplied by reqest!!!!!!!
Read the VB help for the call stack.
No code supplied by request!!!!!!
what do you mean with that man?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 3rd, 2000, 09:50 AM
#9
Member
Oh, I might know this one! =)
You are creating a Cascading Event Loop.
In the Click Event for your button you are triggering the Click Event yet again. That Click Event triggers the event yet again, and so on. As each Click Event triggers the next one NONE of them actually complete execution. The Stack Space stores references to each event currently called and you call so many events that NEVER get completed that it runs out of space.
You'll get the same error with this code:
Private Sub Check1_Click()
Check1.Value = True 'assuming this is a command button
End Sub
Perhaps that simpler code will make the error and what causes it a little more clear. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|