Results 1 to 6 of 6

Thread: Best way to query time

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    In an alarm-clock like application, what is the best way to query the time? Right now I'm using a Timer that fires every 60 seconds, checks the time, and if it's the set time, play a .wav of the user's choice. The drawback is the clock can change, and up to 59 seconds could go by before the sound is played. Now, I could have the timer fire every second, and if it's the right time, play the sound and keep track of that for a minute. It seems to me it would be better to keep the amount of times the timer fires to a minimum, as most of the time the program is not going to need to do anything. Is there a better way I can sync with the time, perhaps with an API call or something?

    Josh

  2. #2
    Fanatic Member faisalkm's Avatar
    Join Date
    Oct 2000
    Location
    Germany
    Posts
    752
    You can create a Timer using the SetTimer API and terminate it using the Killtimer API. You could also use the GetTickCount API for this purpose
    Faisal Muhammed
    Homepage:I Started making it in 1994 ...Still Under Construction
    Using

    Visual Basic 6.0 Enterprise SP5
    Embedded Visual Basic 3.0
    SQL Server 2000
    Windows 2000 Proff
    Delphi 6.0


    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

  3. #3

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Yeah, thanks, I suppose I could set the timer's length to be the difference between the time of the user clicking okay and the time they have set the alarm for.

    A Long in milliseconds should be about 600 hours, right?

    Josh

  4. #4
    Addicted Member
    Join Date
    Apr 1999
    Location
    Freeport
    Posts
    204

    Timer

    I making a program were it total the the employee time from the time he check in say 8:17AM to 5:47PM. Can any show me how to find out the time in Hour in minutes.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    TimeSerial(0, DateDiff("n", "8:17AM" , "5:47PM"),0)
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Junior Member
    Join Date
    Mar 2003
    Posts
    22
    just a thought, might not want to hard code the times like that... kinda defeats the purpose. Try to get around it using textboxes. but of course you already knew that...

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