Helix
asked on
Timer function
Hi everyone, I have a time fuction which displayed the time on my form, what i want to do is when the time displays 9:00 the caption of a label will change
I have tried any different things to do this but with no such luck, ive tried doing:
If Time = "9:00:00" Then
Msgbox = "bla bla bla"
and
If Time = Format("hh....etc etc
msgbox = "bla bla bla"
but nothing happens. ive also tried
If lblTime.Caption = "9:00:00" Then
Msgbox = "bla bla bla"
What am i doing wrong?
Thanks
I have tried any different things to do this but with no such luck, ive tried doing:
If Time = "9:00:00" Then
Msgbox = "bla bla bla"
and
If Time = Format("hh....etc etc
msgbox = "bla bla bla"
but nothing happens. ive also tried
If lblTime.Caption = "9:00:00" Then
Msgbox = "bla bla bla"
What am i doing wrong?
Thanks
Show us the line you use to set the label caption?
ASKER
eh?
This works...
Private Sub Timer1_Timer()
Dim x As Date
x = Time
If FormatDateTime(x, vbShortTime) = "09:00" Then MsgBox "hi helix"
End Sub
You could also do a StrComp
MsgBox StrComp(FormatDateTime(x, vbShortTime), "09:00", vbTextCompare)
Don't know if that helps any....
Private Sub Timer1_Timer()
Dim x As Date
x = Time
If FormatDateTime(x, vbShortTime) = "09:00" Then MsgBox "hi helix"
End Sub
You could also do a StrComp
MsgBox StrComp(FormatDateTime(x, vbShortTime), "09:00", vbTextCompare)
Don't know if that helps any....
It sounds like you are not running this code in a loop. To do what eric0213 suggested, drop a Timer control on your form, set it to enabled with an interval of 500, double click on it, then paste his code in the function.
HTH,
Zaphod.
HTH,
Zaphod.
ASKER
thanks eric0213 that was great, thanks for the help :)
soz i havn't replied in a while, school work :(
one last problem remains though, a message box will keep appearing saying "hi helix", is there a way to only come up once?
soz i havn't replied in a while, school work :(
one last problem remains though, a message box will keep appearing saying "hi helix", is there a way to only come up once?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot, that worked perfectly :)