PDA

View Full Version : Solved: Timer



wildpianist
10-31-2007, 06:58 AM
Hello

I've recently created a label and put some code behind it that displays a timer counting up from 00:00:00.00 however what I want to do is when the label (called Clock) reaches 00:05:00.00 and over I want the text color to change to red.

I assume the code would be something like


If Clock.Caption.Value => "00:05:00.00" then
Clock.Caption.Color = Red



or something of that description (well thats gist of what I want to achieve)

Any Ideas?

Bob Phillips
10-31-2007, 07:18 AM
You would need to set the font colour in the timer code.

wildpianist
10-31-2007, 07:22 AM
I assumed that, however I'm unsure of the code to do that.

:dunno

Bob Phillips
10-31-2007, 07:24 AM
You haven't given enough details to answer that. What sort of control is clock, what does the timer code look like.

As always, a workbook helps a ton.

wildpianist
10-31-2007, 07:30 AM
Sorry xld

Clock is a Label that displays text

The timer code itself adds one second to the Label value (which I have sorted)

All I need basically is the code to tell the text colour of label1 to be Red after the label1 text reaches 00:05:00.00 or over.

Bob Phillips
10-31-2007, 07:38 AM
Sorry, I am going no further without the workbook. It takes too much time to drag the info out of you, and re-create data that you already have.

wildpianist
10-31-2007, 07:40 AM
Understandable! :)

wildpianist
10-31-2007, 02:26 PM
Here is my xls file! :hi:

As I said previously, when the Elapsed.Caption gets to 00:05:00.00 then turn to red and continue until its reset.

:bow: You guys are amazing!

figment
10-31-2007, 02:51 PM
The .forecolor proporty is the one the controls the text color.

wildpianist
10-31-2007, 02:57 PM
So would the code then be

[vba]

If Elapsed.Caption >= "00:05:00.00" then
Elapsed.forecolor

wildpianist
10-31-2007, 02:57 PM
So I'm guessing the code would then be something like


If Elapsed.Caption >= "00:05:00.00" then
Elapsed.forecolor = "red"



Please tell me if I need some magical HEX code in the forecolor bit

Thanks for your help

figment
10-31-2007, 03:03 PM
i am not sure if you need a hex code, but you can probibly use it. in your VB editor go to View->Properties window. if you select the lable in the forum this window will show you most the editable propertys. including the forecolor. it will also show you which codes repersent each color. i on my system the h code for red is &H000000FF&

wildpianist
10-31-2007, 03:16 PM
Sorted!!!! :ole:


If Clock.Caption >="00:05:00.00" then
Clock.ForeColor= &HFF&


Hoorah!!! Thankyou!!! Pretty simple one really lol :D