Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to Stop a Big Loop

How to Stop a Big Loop

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rrocha2
    wrote on last edited by
    #1

    :confused: Hi everyone ... When i am inside a big loop in VB6 (for .. to; if .. then; while .. wend) the form stops responding. How can I make a stop button in the form ?? Thank you ;), Rodrigo

    I 1 Reply Last reply
    0
    • R rrocha2

      :confused: Hi everyone ... When i am inside a big loop in VB6 (for .. to; if .. then; while .. wend) the form stops responding. How can I make a stop button in the form ?? Thank you ;), Rodrigo

      I Offline
      I Offline
      Ian Darling
      wrote on last edited by
      #2

      You need to provide a means to break the loop. This is an example (untested), but you should get the idea:

      dim StopButtonPressed as Boolean
      
      sub MyLongLoopSubroutine()
       StopButtonPressed = false
       while (MyCondition = true ) and (StopButtonPressed = false)
        ' do loop stuff here
        ' DoEvents allows the UI and other windows messages to get through
        DoEvents
       wend
      end sub
      
      sub StopButton_Click()
       StopButtonPressed = true
      end sub
      

      Bear in mind you need to be careful when using DoEvents to keep a user interface responsive, as any actions the user has may interfere with the loop you're running. -- Ian Darling "The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups