Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2004, 09:00 PM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to mjwelker
Default Alarm Clock/How to Compare Set TIme

Thanks to everyone who replied to my post.

My next question is, I'm writing an alarm clock application and I'm not sure how to compare the time entered for the alarm and compare it. I'm assuming I have to use some kind of loop?

Thanks in advance!

Mike

 
Old May 4th, 2004, 09:42 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can use the datediff function for this.
It can go in the timer function you have from the last post so it is tested every time the time changes.

if (DateDiff("s", YourAlarmDateTime, Now()) > 0) then
 'Alarm code
 msgbox("Ring Ring Ring.....")

 'Now that the time is after the alarm time you must either disable the alarm code or change the alarm time.
 'Because it will execute every time the timer function is run.

 'Add 24 hours to alarm
 YourAlarmDateTime= DateAdd("h", 24, YourAlarmDateTime)

end if



======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old May 5th, 2004, 05:04 AM
Authorized User
 
Join Date: Jun 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You need a timer and a combo box (cboTime)

Option Explicit
Dim n As Integer

Private Sub Form_Load()
    Timer1.Enabled = True
    Timer1.Interval = 500
    Call pfLoadcboTime
End Sub

Private Function pfLoadcboTime()
For n = 1 To 24 * 4 - 1
  If n = 12 * 4 Then
   Else
     cboTime.AddItem Format$(TimeSerial(0, 15 * n, 0), "h:nn:ss AM/PM")
   End If
 Next
End Function

Private Sub Timer1_Timer()
 If Time() = cboTime Then
msgBox "Display your message here"
End If
End Sub

See if this helps.

Dunnie





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying Continuous Time (Clock) mjwelker VB How-To 4 April 8th, 2009 05:15 PM
Alarm Program nilgol1 Apache Tomcat 1 April 23rd, 2007 11:29 PM
How To Calculate Monthy Total on-the-clock time Michaniker Access 2 December 2nd, 2005 06:06 PM
Compare time in SQL JaJa SQL Language 2 October 21st, 2004 05:42 PM
set time Dennis JSP Basics 0 December 2nd, 2003 12:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.