Results 1 to 7 of 7

Thread: Making an event happen at a specified time?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    3
    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

  2. #2
    Guest
    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

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    3
    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

  5. #5
    Guest
    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.

  6. #6
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373

    Talking 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
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    3

    Wink

    Thanks everybody...
    I'm sure I'll have more questions soon.
    I think maybe I might like this stuff
    ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width