-
ok folks, I'm a complete neophyte.
I can't figure out how to make an event occur using Time$
Ultimately I want to make my own CD Alarm program but at this point I'd be happy to have something as simple as make a textbox visible at a specified time. i.e. 7:15 P.M.
Is Time$ what I need? and, how do I declare it?
Thanks in advance
-
In a Timer:
Code:
Private Sub Timer1_Timer()
If Format(Time, "Long Time") = "8:00:00 PM" Then Msgbox "SHOW TIME!":Exit Sub: Timer1.Enabled = False
End Sub
-
You can use this code
Code:
Private Sub Timer1_Timer()
If Time = "07:15:00" Then
text1.visible= true
End If
End Sub
Set the timer interval to 1000ms
-
Keeping in mind that I'm VB challenged,
Vlatko, in your snippet does VB know that I want
07:15:00 P.M.?
I tried yours and my text box didn't appear and I wondered if I have the format correct.
The code from Matthew showed it as "Long" so I'm just trying to get this stuff clear in my head.
Also, Time$ isn't useful for my purposes?
Thanks for your patience with a newbie
-
Reason why Vlatko's didn't work is because he forgot the AM/PM so it's not being specified correctly. And mine is basically the same thing.
This is what seems to happen:
Time = 8:00:00
Time$ = 20:00:00
$ = String
I don't have an explanation for why it does that.
So just change Vlatko's code around just a little:
Code:
Private Sub Timer1_Timer()
If Time = "07:15:00 PM" Then
text1.visible= true
End If
End Sub
...and it should work.
-
Sorry to intrude, but
Correct me if i'm wrong, but shoudn't he put the pund sign (#)
to be sure that he is comparing time?
and making sure that the interval timer will work put >=?
Code:
'First add a timer and then
'Just define the interval of time that you want
'the tiemer to be checking for the time.
Option Explicit
Dim MyTime$
Private Sub Form_Load()
Timer1.Interval = 1000 'Interval in milliseconds
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
MyTime = Time
If MyTime >= #7:15:00 PM# Then 'The # for making the time format?
MsgBox "It's Time to take out the Garbage"
Timer1.Enabled = False
End If
End Sub
-
Thanks everybody...
I'm sure I'll have more questions soon.
I think maybe I might like this stuff
;-)