Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Do ... Loop Help

Hi all, I have a problem with my Do ... Loop commands, Well not so much the do .. loops but Labels when call do ... loop.
I have my form with a button on it when you click the button lbl_Info.caption is ment to show "Checking records" and then it does my do ... loop, but the label caption is not shown until after the loop is done :confused:
I have checked the label and it works without the loop but once I put the loop back in no label. Can any one help :confused:

I have also tried setfocus to form before and after the label.caption is called and still not working.
If it helps I am using VB6
[622 byte] By [Chris Yard] at [2007-11-11 10:27:23]
# 1 Re: Do ... Loop Help
Chris, the problem here is that the loop starts quicker than the label can draw. Once the loop has started, unless you have a doevents inside the loop, nothing can happen until the loop finishes.

Try;

Label1.caption = "Chris"
DoEvents
Do
blah blah blah
Loop

Steve.
Steve Grant at 2007-11-11 17:22:43 >
# 2 Re: Do ... Loop Help
Thanks Steve for the quick reply and yes that solved it
Chris Yard at 2007-11-11 17:23:43 >
# 3 Re: Do ... Loop Help
DoEvents is a little too expansive for that, a simple
Label1.refresh
will do the repaint without forcing the flush of all windows events
mstraf at 2007-11-11 17:24:42 >
# 4 Re: Do ... Loop Help
mstraf, the only trouble is, now I have that working I have about 15 labels and 2 progress bars that need to be changing according to the data coming in so DoEvents works just fine for me, but I will bear in mind if I need to refresh 1 or 2 labels
Chris Yard at 2007-11-11 17:25:46 >