Note that there are some explanatory texts on larger screens.

plurals
  1. POStackOverFlowException was Unhandled on For Loop
    primarykey
    data
    text
    <p>I just made my Card Selection Dynamic, instead of a sequence of 5 if/elseif statements. </p> <pre><code>Private Sub PlayElse() Dim StartHeads As Integer Dim CardCheckBoxArray() As CheckBox = {CardCheckBox1, CardCheckBox2, CardCheckBox3, CardCheckBox4, CardCheckBox5, CardCheckBox6, CardCheckBox7, CardCheckBox8, CardCheckBox9, _ CardCheckBox10, CardCheckBox11, CardCheckBox12, CardCheckBox13, CardCheckBox14, CardCheckBox15, CardCheckBox16, CardCheckBox17, _ CardCheckBox18, CardCheckBox19, CardCheckBox20, CardCheckBox21, CardCheckBox22, CardCheckBox23, CardCheckBox24, CardCheckBox25} 'Reset Number Generator Number = (DeckGroup(Rnd.Next(0, DeckGroup.Count)).ID) 'card 1-5 For StartHeads = 0 To 4 If CardCheckBoxArray(StartHeads).Checked = True And DeckGroup(Number).QuantityInteger &gt; 0 Then 'Grab New Card From Deck DeckGroup(Number).QuantityInteger -= 1 Player1HandGroup(Number).QuantityInteger += 1 CardTypeArray(StartHeads) = Player1HandGroup(Number).CardType CardCheckBoxArray(StartHeads).Text = Player1HandGroup(Number).CardNameString NumberArray(StartHeads) = Number Else Call PlayElse() End If </code></pre> <p>This was my original code (note there is an End If. I just didn't want to repeat the code through cards 2-5)</p> <pre><code>If CardCheckBox1.Checked = True And DeckGroup(Number).QuantityInteger &gt; 0 Then 'Grab New Card From Deck DeckGroup(Number).QuantityInteger -= 1 Player1HandGroup(Number).QuantityInteger += 1 CardTypeArray(0) = Player1HandGroup(Number).CardType CardCheckBox1.Text = Player1HandGroup(Number).CardNameString NumberArray(0) = Number </code></pre> <p>Nothing has really changed except, any spot with a 0 is no represented by the corresponding number in the loop. I have several loops similar to this one in my project, yet somehow this is the one that gets a stackoverflow exception. The CardCheckBoxes in the CardCheckBoxArray goes up to 25 because there are 5 players in the game. Any CardCheckBox past 6 in this particular statement simply isn't accessed, since this logic only represents player 1's cards. (Forgot to mention the continue buttons leads to the top of the sub-procedure when the error occurs, highlighting <code>Private Sub Playelse()</code>.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload