Click to See Complete Forum and Search --> : Checking events while in a loop
Rick H
Jan 19th, 2000, 10:22 PM
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?
netSurfer
Jan 19th, 2000, 10:41 PM
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.
Rick H
Jan 19th, 2000, 10:53 PM
Yup, this works a treat, Cheers!
MicahCarrick
Jan 20th, 2000, 12:10 AM
How do you use DoEvent? The MSDN Library seemed a bit vauge to me.
------------------
Micah Carrick
http://micah.carrick.com
micah@carrick.com
ICQ: 53480225
netSurfer
Jan 20th, 2000, 12:13 AM
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. :-)
MicahCarrick
Jan 20th, 2000, 12:19 AM
YES! That's beautiful. Cool, I'll play around with it.
Rick H
Jan 20th, 2000, 12:19 AM
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!
netSurfer
Jan 20th, 2000, 12:21 AM
no problem, this forum is where I learned about it too :-)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.