If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Timing/Pause
I'm setting a label on a form to highlight a status of a comparison.
I need the label to display a colour RED/Fail GREEN/Pass. This needs to be retained for approx. 10 secs and then restore to BLUE/Ready. I've used a simple function I wrote called Pause: st = Time() ft = st + 0.0001 Do Loop Until Time ft This will pause for about 9 secs and continue executing. Problem: When I execute the procedure the label does not change colour but pauses, when I step through the label changes colour and te pause executes. Does anyone know how to change a label colour and caption, and after a specified time return the colour/caption to the default? |
#2
|
|||
|
|||
Timing/Pause
Marcus,
I am in a rush but you could use the Sleep API call to pause the programme and use DoEvents to yield to the processor to change the colour of your label. I hope this helps. Alastair -----Original Message----- I'm setting a label on a form to highlight a status of a comparison. I need the label to display a colour RED/Fail GREEN/Pass. This needs to be retained for approx. 10 secs and then restore to BLUE/Ready. I've used a simple function I wrote called Pause: st = Time() ft = st + 0.0001 Do Loop Until Time ft This will pause for about 9 secs and continue executing. Problem: When I execute the procedure the label does not change colour but pauses, when I step through the label changes colour and te pause executes. Does anyone know how to change a label colour and caption, and after a specified time return the colour/caption to the default? . |
#3
|
|||
|
|||
Timing/Pause
Hi Marcus try something like this
'-----Begin command button sub ----- Private Sub FormButton_Click() ' I used a command button for testing I dont know how you want to trigger your form. Me.TimerInterval = 10000 'start form timer (in milliseconds) ' this if then will set label depending on your test conditions. If TestCondition = MyDesiredCondition Then ' set your conditions here Me.myLabel.ForeColor = 255 ' pick your font color by number Me.myLabel.Caption = "Fail" ' set caption label Else Me.myLabel.ForeColor = 6723891 'Set myLabel to your form label name. Me.myLabel.Caption = "Pass" End If End Sub '-----End command button sub ----- '-----Begin Form timer sub ----- Private Sub Form_Timer() Me.myLabel.ForeColor = 16711680 'Timer changes label when interval has passed Me.myLabel.Caption = "Ready" Me.TimerInterval = 0 'turn timer back off End Sub '-----End Form timer sub ----- There are other methods to do time delays, such as setting up a loop function but they tend to tie up the CPU while executing, using the form timer takes up very little CPU time. The problem with your loop I believe is that every time your procedure executes, it gets the current time and then has to loop all over again, You in essense have created a moving target using Time(). If you need to use a loop try using an arbitrary number instead such as lngNumber = 100000 do until lngNumber = 0 lngNumber = lngNumber - 1 Loop Hope this helps answer your question Fred. "Alastair MacFarlane" wrote in message ... Marcus, I am in a rush but you could use the Sleep API call to pause the programme and use DoEvents to yield to the processor to change the colour of your label. I hope this helps. Alastair -----Original Message----- I'm setting a label on a form to highlight a status of a comparison. I need the label to display a colour RED/Fail GREEN/Pass. This needs to be retained for approx. 10 secs and then restore to BLUE/Ready. I've used a simple function I wrote called Pause: st = Time() ft = st + 0.0001 Do Loop Until Time ft This will pause for about 9 secs and continue executing. Problem: When I execute the procedure the label does not change colour but pauses, when I step through the label changes colour and te pause executes. Does anyone know how to change a label colour and caption, and after a specified time return the colour/caption to the default? . |
Thread Tools | |
Display Modes | |
|
|