Visual Basic (System Stack Overflow Exception)
Hi everyone. I am trying to code my own Space Invaders program for my college course. I am working on this tutorial on YouTube. Link provided here: https://www.youtube.com/watch?v=SsI2GVO1Hxs I have gotten to about 12:00 on the video. As soon as I try to run the code to get my aliens to run right across the screen it doesnt happen and i just get the: "System.StackOverflow exception. 'Exception of type system.stackoverflow exception was thrown. ? I will paste my code on here so everyone can see it. I have pretty much copied the tutorial word for word up until this point so i dont know where i have gone wrong. Bear in mind i am only an absolute beginner so I dont know much at the moment. Still learning. Please help :( Public Class Form1 #Region "Variables" Dim Aliens(18) As PictureBox Dim Lef As Boolean Dim Rig As Boolean Dim movealien As Integer = 3 #End Region Region "Buttons" Private Sub Button1_Click(sender As Object, e As EventArgs) Handles StartGame.Click StartGame.Hide() QuitGame.Hide() Panel1.Show() Movecomp.Enabled = True Movecomp.Start() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles QuitGame.Click End Sub #End Region #Region "Timers" Private Sub Movecomp_Tick(sender As Object, e As EventArgs) Handles Movecomp.Tick If Lef = True Then MotherShip.Left = MotherShip.Left - 2 End If If Rig = True Then MotherShip.Left = MotherShip.Left + 2 End If movealiens() End Sub #End Region Private Sub Label2_Click(sender As Object, e As EventArgs) End Sub Private Sub MotherShip_Click(sender As Object, e As EventArgs) Handles MotherShip.Click End Sub Region "keypresses" Private Sub movecompleft(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown If e.KeyValue = Keys.A Then Lef = True End If If e.KeyValue = Keys.D
1/31/2020 4:24:16 PMharry
10 AnswersNew Answer
Copy the code to the playground and share the link from there ( as you've shared the YouTube link ).
harry go to the playground, select CS from the bottom-left plus icon then paste your code inside and save it, then share the code on here
As a general rule, a stack overflow exception is caused by a recursive algorithm where the depth of recursion has exceeded the (typically) fixed stack limit. This is usually a result of a bug in the algorithm, but it may also be caused by the data structure you are applying the algorithm to being too "deep". https://stackoverflow.com/questions/1450192/what-is-a-stackoverflow-exception-in-vb-net
The youtube link, is a link to the tutorial i am following
https://code.sololearn.com/#html Is this how i do it ?
https://code.sololearn.com/WpMIkSB1NcK4/# Does this work ?
Hi there. Thank you for your reply. But my college course is requiring me to use this VB IDE to complete it. Do you know how I can solve this problem. I am just trying to get this out of the way so i can finish my course and start learning Java lol
I don't have VB IDE to debug. Does the error message tell you which line the error occurs? Bed time here. In case nobody relay answering this thread, I'll be back about 8 hours later.
Gordon. Did you see my link which takes you to the code on the Playground ?