Results 1 to 9 of 9

Thread: Interesting, out of stack space

  1. #1

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986

    Wink

    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.

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Maybe the click event fires when the value is changed.

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Cool


    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...



    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  4. #4
    Lively Member
    Join Date
    Aug 2000
    Location
    Trondheim, Norway
    Posts
    65

    Lightbulb

    It will work if you put the code in MouseUp event instead...

    D

  5. #5

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  6. #6
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Angry

    While in break mode to a Ctrl+L !!!!!!!!


    no code supplied by reqest!!!!!!!

    Read the VB help for the call stack.
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  7. #7
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    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.

  8. #8

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  9. #9
    Member
    Join Date
    Aug 2000
    Posts
    45

    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. =)

    -Gregg
    -NoOBie At LaRg3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width