Visual Basic 6 help needed once again - display in a loop

dullard

Elite Member
May 21, 2001
26,201
4,871
126
Thanks for those who helped get me on the right track to start with. I'm getting a lot accomplished in learning VB considering the library has all the VB books checked out and since my boss was too cheap to buy the help files for the first few days.

I've got a question about printing in a loop. I need to do something like this (simplified from the real code of course):

Do while ...
    .
    .
    .
    GasTemperature = FunctReadTemp(...)
    lblTemperature = GasTemperature
    .
    .
    .
Loop

My problem is that only the last temperature is ever printed. So I tried adding:

    lblTemperature.refresh

to the loop code. That now prints everything, but the whole label box has an annoying flash (including the border). Is there a way to eliminate the flashing, and just print the numbers?

Now for the more difficult question. Is it possible to have a loop like that running on a form while still accessing the command buttons/option buttons/etc on the form? Basically I would like a label that continuously shows the temperature running in the background while I still have full access to that form.
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
use double buffering or dont update the temp in every iteration of the loop, wait for every 10 iterationsthe flashing should be reduced or eliminated
 

rufruf44

Platinum Member
May 8, 2001
2,002
0
0
1st question is answered by Ameesh. 2nd question, take out the loop and use a timer to determine when to redisplay the temperature.
 

dullard

Elite Member
May 21, 2001
26,201
4,871
126
I had tried printing only every 100th loop, but that was still flashy (it is basically the border turning white that is annoying - is there a way to have the border not refresh?) Printing every 1000 loops is better but displays too infrequently. I guess I can turn off the border and be fine - I'm just picky. How do you do double buffering with VB? I'm a newbie at visual programming, but the help only mentions double buffering in Visual C.

I hadn't thought about timers (again, I'm new to this), but I guess that might work. Unfortunately each timer event will be a big slowdown, but it will work. I really need an event that occurs whenever the program is idle...

Could you help me understand the timers a bit? Suppose I was in a long loop in a subroutine and the specified amount of time on the timer has elapsed. Does the timer command (A) wait for the other subroutine to end, (B) wait for the loop to end, or (C) temporarily pause the loop until the timer command has finished? If the answer is (A) or (B) then timers will work. If it is (C) then the timer will be a nightmare.

Thanks for your help.
 

dullard

Elite Member
May 21, 2001
26,201
4,871
126


<< Put a doevents in after you update the box. >>



I haven't seen the doevents command yet. Is this a correct interpretation of its function?
1) pause a routine
2) check if other commands need to be processed
3) if other commands exist, perform them
4) unpause the routine

If that is what it does, then that is exactly what I need.