CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2000
    Posts
    48

    Long Loop; how to stop it with button?

    I have a big loop (read data with COM) and I would like to stop the loop
    with a pressed button - How can I stop the loop in an easy way? I do not want to use a timer which reads the data in intervalls (cause this will fill the message queue)
    Thank you!!!


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Long Loop; how to stop it with button?

    in general section:
    dim blnExit as boolean
    'your loop inside the form
    do while ....
    DoEvents 'this will enable processing informations and command meanwhile
    'so be sure to lock all controls excepted the cancel button!
    if blnExit = true then exit do
    ...
    loop
    'your stop button
    private sub command1_click()
    blnExit = true
    end sub

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Aug 2000
    Posts
    48

    Re: Long Loop; how to stop it with button?

    Great! Thank you very much!!!


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

Featured