System overflow with simple arithmetic?

Posts 111 of 11 · Page 1 of 1
System overflow with simple arithmetic?
For some weird reason I get a system overflow with this:

[php]
Public Class Form1
Dim x As Integer = 2
Dim value As Integer = 0
Private Sub c()
a:
If 1 + 1 = x Then
value = value + 4
End If
GoTo a
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
c()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label2.Text = value
End Sub
End Class
[/php]

PS. im back.
man wtf... are you dumb? (sry for flame)

you have it on a infinite loop...

Go to A -> Do the if -> Go to A -> Do the if... over and over

Oh.. and GoTo's is a bad a practice of programming.
And wtf is that anyways? o_O

Nonsense 2 me.

Brinuz 4 president.
tell me what this is!!!
That looks like Batch and DOS.... Anyway, what is the purpose of this code?

Save this as a .bat file and this explains basically what you are trying to do:

Code:
@echo off
set /a x=2
set /a value=0
set /a add=1+1

goto a

:a
if %x% == %add% (
 set /a value += 4
 echo %value%
 goto a
)
pause
Even though I have a pause there which basically pauses the .bat file, it ignores it and loops :a infinately...
purpose is to find the calculations per second of a processor at 50% load (50% because of vb limitations) so this is what I came up with, but strangely, with this code it does not crash...

[php]
label3.text = label3.text + 4
label3.refresh()
[/php]

(and i know its an infinite loop)
Quote Originally Posted by mnpeepno2 View Post
purpose is to find the calculations per second of a processor at 50% load (50% because of vb limitations) so this is what I came up with, but strangely, with this code it does not crash...

[php]
label3.text = label3.text + 4
label3.refresh()
[/php]

(and i know its an infinite loop)
if you want a program to get into an infinite loop, why using a GoTo? and not a While(true)? just wondering.. And of course it won't crash because while it refresh's, it also sends the information to the GUI, which lets you see the info of those calculations.

On a while loop or Goto loop, it will freeze the GUI because it won't send any info to the GUI, any paint, anything. Which will lead into a crash.

PS: You know that there is more code running beside the one you usually see right?
Quote Originally Posted by 'Bruno View Post
if you want a program to get into an infinite loop, why using a GoTo? and not a While(true)? just wondering.. And of course it won't crash because while it refresh's, it also sends the information to the GUI, which lets you see the info of those calculations.

On a while loop or Goto loop, it will freeze the GUI because it won't send any info to the GUI, any paint, anything. Which will lead into a crash.

PS: You know that there is more code running beside the one you usually see right?
i thought goto might fix the problem.

PS: Yes, but the Gui is being controlled by the graphics card processor.
Quote Originally Posted by mnpeepno2 View Post
i thought goto might fix the problem.

PS: Yes, but the Gui is being controlled by the graphics card processor.
thats not the issue, you are freezing the code in that place. the code to refresh the gui, to the GUI paint won't get reached...
k got it.
/short
Use a backgroundworker for your infinite loop, or a seperate thread so it won't hang the UI thread.
Posts 111 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?