+ Reply to Thread
Results 1 to 5 of 5

Out of Stack Space

Hybrid View

Phoenix5794 Out of Stack Space 08-29-2012, 07:33 PM
shg Re: Out of Stack Space 08-29-2012, 07:41 PM
Phoenix5794 Re: Out of Stack Space 08-29-2012, 07:54 PM
shg Re: Out of Stack Space 08-29-2012, 08:21 PM
Phoenix5794 Re: Out of Stack Space 08-29-2012, 08:44 PM
  1. #1
    Forum Contributor
    Join Date
    01-09-2012
    Location
    Rochester Hills, United States
    MS-Off Ver
    Excel 2010
    Posts
    161

    Out of Stack Space

    Private Sub ToggleButtonEnglish_Click()
        Call Clear
        ToggleButtonEnglish.Value = True
    End Sub
    
    Private Sub ToggleButtonMetric_Click()
        Call Clear
        ToggleButtonMetric.Value = True
    End Sub
    
    Sub Clear()
        ToggleButtonEnglish.Value = False
        ToggleButtonMetric.Value = False
    End Sub
    Why does this give me an Out of Stack Space error?

    It's only being called when I click on that toggle button, so it shouldn't be looping through, should it?

    Thanks.

    Essentially I'm simply trying to make it so only one ToggleButton is active at one time. I've tried several things on my own (If/Else statements) along with other's online, but I've gotten nowhere. This is the most recent and doesn't do as it seems it should.
    Nothing is absolute - a paradox in itself.

    Indirect Dynamic Data Validation (scroll to the bottom of the page)

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Out of Stack Space

    Changing the value of a togglebutton triggers its click event, so ...
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    01-09-2012
    Location
    Rochester Hills, United States
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Out of Stack Space

    Oh, I see. How can I avoid that then? There are two scenarios for each toggle button:

    Private Sub ToggleButtonEnglish_Click()
        If ToggleButtonEnglish.Value = True Then
            ToggleButtonEnglish.Value = True
            ToggleButtonMetric.Value = False
    
        ElseIf ToggleButtonEnglish.Value = False Then
            ToggleButtonEnglish.Value = True
            ToggleButtonMetric.Value = False
    
        End If
    End Sub
    And Vice-Versa for Metric.

    As you mentioned:
    You need to create a module-level flag (e.g., bBusy). When a button is pushed, if the flag is set, exit. If the flag is not set, set the flag, proceed with the code, and clear the flag.
    Last edited by Phoenix5794; 08-29-2012 at 07:58 PM.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Out of Stack Space

    Dim bItsMe As Boolean
    
    Private Sub ToggleButton1_Click()
        If bItsMe Then Exit Sub
        
        bItsMe = True
        ToggleButton2.Value = False
        ToggleButton1.Value = True
        bItsMe = False
    End Sub
    
    Private Sub ToggleButton2_Click()
        If bItsMe Then Exit Sub
        
        bItsMe = True
        ToggleButton1.Value = False
        ToggleButton2.Value = True
        bItsMe = False
    End Sub
    But in practice, I'd use an option button instead, which has by design 1-of-N behavior.

  5. #5
    Forum Contributor
    Join Date
    01-09-2012
    Location
    Rochester Hills, United States
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Out of Stack Space

    I gotcha.
    The toggle button just seemed more intuitive (aesthetics-wise) in my case. Thanks for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1