VB icon

Countdown Till Midnight

Email
Submitted on: 11/8/2017 3:54:03 AM
By: PAIK 
Level: Beginner
User Rating: Unrated
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 498
 
     ' This code will show you the time remaining till midnight in a manner of a countdown watch. ' This is accomplished by using 2 lines of code only.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Countdown Till Midnight
' Description:' This code will show you the time remaining till midnight in a manner of a countdown watch.
' This is accomplished by using 2 lines of code only.
' By: PAIK
'**************************************

' All what you will need is to put a Label 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 Label.
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' Explanation of the used function: Fomat(Datediff ("n", now ,date+1 ) - time , "hh:nn:ss") 
'-------------------------------------------------------------------------------------------------------------------------------------------------
' DatediffReturns the number of intervals between two dates.
' "n"Argument used to specify Minutes (you could use: "s" for seconds, "h" for hours; "d" for days; ...
' now Used to specify current date and time
' date + 1Date (is the current date) (+1) means add 1 day to the current day => tomorrow
' time Used to specify the current time
' FormatDisplay the output in the specified format {in our case: "hh:nn:ss" hour:minutes:seconds
'-------------------------------------------------------------------------------------------------------------------------------------------------
Label1.caption = Fomat(Datediff ("n", now ,date+1 ) - time , "hh:nn:ss") 
' Check if you reached midnight and fire a message.
If Format(DateDiff("n", Now, Date + 1) - Time, "hh:nn:SS") <= "00:00:01" Then MsgBox "Midnight Is Now!!!!", vbInformation + vbOKOnly, "Countdown till midnight"


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.