Results 1 to 3 of 3

Thread: triggering a while loop when button is clicked

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    9

    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!

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: triggering a while loop when button is clicked

    VB Code:
    1. Dim looping As Boolean
    2.  
    3. Private Sub cmdStart_Click()
    4. looping = True
    5.     If looping Then
    6.         StartLoop
    7.     End If
    8. End Sub
    9.  
    10. Private Sub StartLoop()
    11. While looping
    12.     DoEvents    'So other things can still run ie stoping loop
    13. Wend
    14. End Sub
    15.  
    16. Private Sub cmdStop_Click()
    17. looping = False
    18. End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    9

    Re: triggering a while loop when button is clicked

    thanks a bunch! i didnt know about DoEvents before! it solved the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width