|
-
Jan 5th, 2001, 12:33 AM
#1
Thread Starter
Frenzied Member
If youre program is based on a loop (a very important one), how can i user stop the loop with the click of a button?
-
Jan 5th, 2001, 12:58 AM
#2
New Member
declare a public variable loopstop as boolean
public loopstop as boolean
sub Stop_click()
loopstop = true
end sub
in your loop function write this tag:
do until loopstop = false
.
..
...
loop
or
while loopstop = false
.
..
wend
hope this helps
-
Jan 5th, 2001, 12:59 AM
#3
Hyperactive Member
This can be done by geting the loop to check for events at the end of each cycle.
I wipped up an app that test it.
Just start a new project put to buttons on it. Command 1 starts the loop. Command2 then stops it and displays the counter value
Good Luck
Option Explicit
Private blnstop As Boolean
Private lngCounter As Long
Private Sub Command1_Click()
blnstop = True
End Sub
Private Sub Command2_Click()
For lngCounter = 0 To 100000000
If blnstop Then
MsgBox "Stopped at " & lngCounter
blnstop = False
Exit For
End If
DoEvents
Next lngCounter
End Sub
-
Jan 5th, 2001, 01:00 AM
#4
New Member
sorry
on that first loop, it should be:
do until loopstop = TRUE
loop
-
Jan 5th, 2001, 01:02 AM
#5
Addicted Member
Code:
Private Sub Command1_Click()
Dim x
For x = 1 To 100000
If Me.Check1.Value = 0 Then
Exit For
Else
Print x
End If
Next
End Sub
-
Jan 5th, 2001, 02:04 AM
#6
PowerPoster
How abt this?
Code:
Dim X As Integer
Do While X < 1000
X = X + 1
DoEvents
Loop
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
|
Click Here to Expand Forum to Full Width
|