-
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.d
Public Function Delen() As String
' vraagt hier voor een volgende kaart.
Dim getal2 As Integer
Dim resultaat2 As String
getal2 = randomGetal2.Next(1, 52)
If checkGebruikt(getal2) Then
resultaat2 = CStr(getal2) '& "-" & CStr(type)
arrayKaarten(tellerArray) = getal2
tellerArray += 1
ScoreSpeler = ToevoegenScore(getal2)
Return resultaat2
Else
Delen()
End If
End Function
Here I get "An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"
Please HELP
-
I suppose the problem is in the line in bold, so the problem is in randomGetal2, not in the procedure you sent us.
The first things to look for in StackOverflowException is an endless loop or recursion. Something gets called over and over again with a condition that prevents it from ever returning or exiting.
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
-
in the GDA there is "Dim randomGetal2 As New Random"
-
And what is the GDA exactly? A quick search on the Internet seems to connect it with something in German, and I cannot see what it is used for.
It is not part of the framework (at least not in the English version). You should contact the people who provided you with that GDA.
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
-
I made it myself, the declaration is Dim randomNumber As New Random and then I put a randomnumber into a variable like getal = randomNumber.next(1,52)
-
Then, the code for your Next method is probably the one that causes the stack overflow. You should post that one.
Even better, there is a random class in .NET (System.Random). Why don't you used it?
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
-
Dim randomnumber as new random is the random class in .NET, in this function it works:
Public Function geefEerteKaartenDeler() As String
Array.Clear(arrayKaarten, 0, arrayKaarten.Length - 1)
tellerArray = 0
Dim getal As Integer
' Dim type As Integer
Dim resultaat As String
getal = randomGetal.Next(1, 52)
If checkGebruikt(getal) = False Then
resultaat = CStr(getal) '& "-" & CStr(type)
arrayKaarten(tellerArray) = getal
tellerArray += 1
Return resultaat
ScoreDeler = ToevoegenScore(getal)
Else
geefEerteKaartenDeler()
'Return "fout"
End If
'type = randomGetalType.Next(1, 4)
End Function
-
OK, I get it, and I see something I had not seen that could trigger the error.
Public Function Delen() As String
' vraagt hier voor een volgende kaart.
Dim getal2 As Integer
Dim resultaat2 As String
getal2 = randomGetal2.Next(1, 52)
If checkGebruikt(getal2) Then
resultaat2 = CStr(getal2) '& "-" & CStr(type)
arrayKaarten(tellerArray) = getal2
tellerArray += 1
ScoreSpeler = ToevoegenScore(getal2)
Return resultaat2
Else
Delen()
End If
End Function
Delen calls itself in the Else (recursion). I suppose that the checkGebruikt(getal2) call always returns 0 or False, so you keep going into the Else.
You have an infinite loop, as I stated in the first post. The line in bold sent me on a wrong track in my evaluation of the problem.
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
-
Thanks , you helped good (y)
Similar Threads
-
By Govil Manish in forum .NET
Replies: 1
Last Post: 09-25-2006, 07:33 AM
-
By Mike Wilis in forum .NET
Replies: 0
Last Post: 04-28-2002, 07:07 PM
-
Replies: 8
Last Post: 12-08-2001, 10:30 AM
-
By Tahui in forum VB Classic
Replies: 2
Last Post: 11-22-2000, 10:24 PM
-
By abeji in forum VB Classic
Replies: 20
Last Post: 10-13-2000, 12:22 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks