0

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

31st Jan 2020, 4:24 PM
harry
9 ответов
+ 2
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
31st Jan 2020, 4:29 PM
Gordon
Gordon - avatar
0
The youtube link, is a link to the tutorial i am following
31st Jan 2020, 4:30 PM
harry
0
https://code.sololearn.com/#html Is this how i do it ?
31st Jan 2020, 4:32 PM
harry
31st Jan 2020, 4:40 PM
harry
0
The error message indicates that you are entering an infinite recursion. 1. Illustrating infinite recursion with JavaScript https://code.sololearn.com/W5w1SN6LS9Q0/?ref=app 2. Visual Basic documentation at Microsoft Docs https://docs.microsoft.com/en-us/dotnet/visual-basic/ It is better to learn "Hello World" before coding a game. 3. Stop learning visual basic You are following a 2014 tutorial. Nowadays Microsoft uses C# instead of Visual Basic. So I suggest you to learn C# with WPF framework instead. C# documentation at Microsoft Docs https://docs.microsoft.com/en-us/dotnet/csharp/ WPF documentation at Microsoft Docs https://docs.microsoft.com/en-us/dotnet/framework/wpf/ C# Tic Tac Toe Game Tutorial https://youtu.be/mnTyiUAHuVk C# Racing Game Tutorial https://youtu.be/xyggRDkoOwU
31st Jan 2020, 5:09 PM
Gordon
Gordon - avatar
0
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
31st Jan 2020, 5:29 PM
harry
0
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.
31st Jan 2020, 6:12 PM
Gordon
Gordon - avatar
0
Gordon. Did you see my link which takes you to the code on the Playground ?
31st Jan 2020, 6:27 PM
harry
0
Hi can you share your code with me? atieh830@gmail.com
30th May 2023, 7:57 AM
Atieh Salimi
Atieh Salimi - avatar