p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Visual Basic 2005 Basics (http://p2p.wrox.com/forumdisplay.php?f=137)
-   -   Stack Overflow Exception?? (http://p2p.wrox.com/showthread.php?t=63675)

Apocolypse2005 November 11th, 2007 09:10 AM

Stack Overflow Exception??
 
Everytime i run my code i get this stack overflow exception and its troubleshooting tips are make sure there isn't and infinite loop or recursion. What does all this mean?

Cheers

------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!

dparsons November 11th, 2007 12:19 PM

To get a better idea of what is causing this, open your call stack window in VS (Debug --> Windows --> Call Stack) and that should give you an idea of what is causing it. I assume you know what an infinte loop is and recursion can also be likend to an infite loop if implemented incorrectly, consider:

Private Sub foo()
   Dim i as Integer = 0
   While i = 0
     foo()
   End While
End Sub

So recursion is the technique whereby a Method or Function calls itself until some condition is met but, as the example above shows, there is no condition to stop the recursion since i is never incremented the While loop will continue to call the method foo()

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========

Chris Van Duin January 17th, 2008 07:06 PM

You can also get a recursion loop if your code is firing off multiple events. For example. You might handle a textchanged event on a textbox control and then modify the text accordingly, like change to uppercase for user input, but this triggers off the textchanged event again, and so on.


All times are GMT -4. The time now is 01:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.