bpl5000
asked on
Stopping code execution with a stop button on a VB6 form
I will be using the following code in a VB6 program to cause the CPU to kick up. I will have a start and stop button on the form, but I'm not sure how to have the stop button cancel the execution of the code? Here is the code that will be in the start button sub:
Dim goal
Dim before
Dim x
Dim y
Dim i
goal = 2181818
Do While True
before = Timer
For i = 0 to goal
x = 0.000001
y = sin(x)
y = y + 0.00001
Next
y = y + 0.01
Loop
How would I make the stop button work?
Thanks! BPL
Dim goal
Dim before
Dim x
Dim y
Dim i
goal = 2181818
Do While True
before = Timer
For i = 0 to goal
x = 0.000001
y = sin(x)
y = y + 0.00001
Next
y = y + 0.01
Loop
How would I make the stop button work?
Thanks! BPL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeah...you definitely need that DoEvents. Otherwise the Stop button press won't get processed until the While loop drops out.
ASKER
That works great! Thanks for the help!
...
Do While True
if isExist then exit do
DoEvents
before = Timer
For i = 0 to goal
x = 0.000001
y = sin(x)
y = y + 0.00001
Next
y = y + 0.01
Loop
...