'************************************** ' Name: Countdown Till Midnight ' Description:' This code will show you ' the time remaining till midnight in a ma ' nner of a countdown watch. ' This is accomplished by using 2 lines ' of code only. ' By: PAIK ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** ' All what you will need is to put a Lab ' el on a form and a Timer ' Set the timer: interval to 500 ; ' and paste this code. ' Note: For best results of display use ' the font DigifaceWide for your added Lab ' el. '/////////////////////////////////////// ' //////////////////////////////////////// ' //////////////////////////////////////// ' //////////////////////////////////////// ' /////////////// ' Explanation of the used function: Foma ' t(Datediff ("n", now ,date+1 ) - time , ' "hh:nn:ss") '--------------------------------------- ' ---------------------------------------- ' ---------------------------------------- ' -------------------------- ' Datediff Returns the number of interva ' ls between two dates. ' "n"Argument used to specify Minutes (y ' ou could use: "s" for seconds, "h" for h ' ours; "d" for days; ... ' nowUsed to specify current date and ti ' me ' date + 1 Date (is the current date) (+ ' 1) means add 1 day to the current day => ' tomorrow ' timeUsed to specify the current time ' Format Display the output in the speci ' fied format {in our case: "hh:nn:ss" hou ' r:minutes:seconds '--------------------------------------- ' ---------------------------------------- ' ---------------------------------------- ' -------------------------- Private Sub Timer1_Timer() Label1.Caption = Format(DateDiff("n", Now, Date + 1) - Time, "hh:nn:ss") If Format(DateDiff("n", Now, Date + 1) - Time, "hh:nn:SS") <= "00:00:01" Then MsgBox "Midnight Is Now!!!!", vbInformation + vbOKOnly, "Countdown till midnight" End Sub