Results 1 to 8 of 8

Thread: Checking events while in a loop

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    While running the following code:

    Do While (err = 0)
    err = CANPC_read_ac(param)
    frmMonitor.StatusBar1.SimpleText = "No new Can event"
    Loop

    none of my events (cancel_click) etc work. The program is in a loop waiting for err to change from zero. Is there anyway of checking the "event list" so that my buttons still work?


  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    I may be wrong but can't you put a DoEvents inside the loop? I haven't used it myself but I've seen it in code before. I believe that what it will do is check to see if there are any events waiting and it will do them.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    Yup, this works a treat, Cheers!

  4. #4
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    How do you use DoEvent? The MSDN Library seemed a bit vauge to me.

    ------------------
    Micah Carrick
    http://micah.carrick.com
    [email protected]
    ICQ: 53480225


  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    Micah, from what I've seen, basically you just put:

    DoEvents

    in your code and what it will do is check to see if there are any events (like mouse clicks or keypresses) and it will run them and then come back to your code. I think. :-)

  6. #6
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    YES! That's beautiful. Cool, I'll play around with it.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    DoEvents runs all the events saved up in the event list while your program was away doing much more interesting things.

    In my case events were`nt getting handled at all because my program was in a Do While loop. Adding "DoEvents" in my loop cures this problem.

    Thanks for the advice netsurfer. Cheers!

  8. #8
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    no problem, this forum is where I learned about it too :-)

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