triggering a while loop when button is clicked
hi,
i have a slight problem here.
i have a form with one start and one stop button. When you click the start button i want to execute a routine over and over again till the stop button is pressed.
i dont know how to do the while loop. should i put it in a function and trigger that on Buttonclick?
i hope you can help me out here!
Re: triggering a while loop when button is clicked
VB Code:
Dim looping As Boolean
Private Sub cmdStart_Click()
looping = True
If looping Then
StartLoop
End If
End Sub
Private Sub StartLoop()
While looping
DoEvents 'So other things can still run ie stoping loop
Wend
End Sub
Private Sub cmdStop_Click()
looping = False
End Sub
Re: triggering a while loop when button is clicked
thanks a bunch! i didnt know about DoEvents before! it solved the problem :)