Results 1 to 6 of 6

Thread: DoEvents question (VERY simple)

  1. #1

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510

    Question

    I have some rather long Do...Loop's in my program.....I have put the DoEvents command inside some of the longer loops, and my program is starting faster and there are no visual screen problems with repainting now.

    My question is:

    Is there any negative effect of the DoEvents command or using too many DoEvents commands??

    Please advise.

    Thanks!!!
    "If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"

  2. #2
    Guest
    The only negative effect there is is that your program runs slower, because it gives the OS time to repaint the screen and do whetever it needs to do.

    You must be careful though, it is possible to close a form that's running a loop with doevents... possibly crashing the program.

    You can get around that by setting some variable when the loop runs and check that var when the user wants to close the form, and do not allow it to unload. Or stop the loop and then unload.

    Gerco.

  3. #3

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    I see.

    The reason I added the DoEvents is because when the program was in the loop, which is a SUB in a MODULE, the screen was showing large white blocks for some of the controls....and it was taking a long time after issuing the command.

    After adding the: openforms = DoEvents
    the program started with lighting speed and I had no white spaces.

    Is this practice ok??

    P.S. Thanks for the info.
    "If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    you can also test the actual DOEvents in the loop

    if DoEvents = 0 then exit loop
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    Guest
    Sure you can do that... the white blocks are because the OS doesn';t have time to paint your program's window.

    To allow the OS some time, use DoEvents.

    Gerco.

  6. #6

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    Thanks again!

    Your help is extremely appreciated!!!!
    "If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"

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