Stop udførelse uden at lukke application
Hej.jeg har et program der starten en udregning, som tager ufatteligt lang tid. Jeg vil gerne have en knap der stopper denne udregning, uden at lukke hverken formen eller programmet ned.
Den stopper heller ikke med at regne selvom jeg trykker luk..
Nogen idéer?
Følgende procedure skal stoppes... eller pauses
Button1:
Do
Application.DoEvents() ' Will make sure it doesn't freeze while calculating.
Number += 1 ' The number adds one for each attempt
LabelNumber.Text = "Trying: " & Number
For i = 1 To 20 ' create a loop that tries to divide by 1 to 20.
If Not Number / i = Number \ i Then ' This checks if the number can be divided by i without any remainder
' by checker whether or not the number with all decimals is the same
' as the number without decimals.
Exit For
ElseIf Number / i = Number \ i And i = 20 Then ' if this is true,
' the number has been divided by each number from 1 to 20 without any remainder. Then Number is
' the answer (Number will contain 232792560)
TextBox1.Text = Number
LabelNumber.Text = "Solved!"
Timer1.Stop()
Exit Do
End If
Next
Loop