#17724 - 03/06/02 05:53 PM
VB countdown timer
|
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis
Junior Member
|
Junior Member
Joined: Mar 2002
Posts: 9
Ohio
|
OK, just wondering if someone had a snippit of vb code to do a countdown timer, to go from the current date, to a set date, that will display the number of Days, Hours, Minutes, and Seconds till the target date. I've just started playing with VB and would appreciate some guidance just for this issue. I'm sure in the future I'll be better able to sort these things when I am more familiar with VB's attitude and thought process. Many thanks! 
-=[Do Not tap on the glass. Do Not feed the geeks. They are on a strict diet of caffeine and no sleep.]=-
|
|
|
#17728 - 03/07/02 12:37 AM
Re: VB countdown timer
|
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis
Junior Member
|
Junior Member
Joined: Mar 2002
Posts: 9
Ohio
|
I got it figured out, fyi :
Private Sub Timer1_Timer() Dim MyDate, MyTime, MyHour, MyMinute, MySec Dim TgtDate, TgtTime, TgtHour, TgtMinute, TgtSec
'Change TgtDate to whatever date you want to count down to. TgtDate = #8/17/2002# TgtHour = 24 TgtMinute = 60 TgtSec = 60
MyDate = DateDiff("d", Now() + 1, TgtDate) MyHour = TgtHour - Format(Now(), "hh") MyHour = Format(MyHour, "0#") MyMinute = TgtMinute - Format(Now(), "nn") MyMinute = Format(MyMinute, "0#") MySec = TgtSec - Format(Now(), "ss") MySec = Format(MySec, "0#") label1 = MyDate & " Days " & MyHour & ":" & MyMinute & ":" & MySec End Sub
-=[Do Not tap on the glass. Do Not feed the geeks. They are on a strict diet of caffeine and no sleep.]=-
|
|
|
#17732 - 03/07/02 01:57 AM
Re: VB countdown timer
|
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis
Junior Member
|
Junior Member
Joined: Mar 2002
Posts: 9
Ohio
|
I stand corrected, then. Thank you very much. Bear with me as I just started VB 3 days ago. :| I'm sure I'll have more "issues" (just call me M$ Certified. Failure is not an option, it comes bundled with the software.) Anywho.. onto more learning!
-=[Do Not tap on the glass. Do Not feed the geeks. They are on a strict diet of caffeine and no sleep.]=-
|
|
|
#17734 - 03/08/02 01:43 AM
Re: VB countdown timer
|
Joined: Mar 2002
Posts: 256
ninjaneo
UGN Security Staff
|
UGN Security Staff

Joined: Mar 2002
Posts: 256
Likes: 1
CA, USA
|
'An improvment to sr's code.
TgtDate = #3/7/2002 6:35:00 PM# Label1 = DateDiff("d", Now(), TgtDate) & " day(s) " & Format(TgtDate - Now(), "hh:nn:ss") If GetPiece(Label1.Caption, " ", 1) = "0" Then If Now() > Date & " " & Time Then Exit Sub End If End If Label1.Caption = Replace(Label1.Caption, "-", "Occured ") & " ago."
'Another function is used... here it is...
Function GetPiece(From As String, delim As String, index) As String Dim temp$ Dim Count Dim Where ' temp$ = From & delim Where = InStr(temp$, delim) Count = 0 Do While (Where > 0) Count = Count + 1 If (Count = index) Then GetPiece = Left$(temp$, Where - 1) Exit Function End If temp$ = Right$(temp$, Len(temp$) - Where) Where = InStr(temp$, delim) DoEvents Loop If (Count = 0) Then GetPiece = From Else GetPiece = "" End If End Function
Im not sure if it is accurate or not. Brief testing proves it to be correct but I dont know you guys can check that out
|
|
|
|
Forums41
Topics33,701
Posts68,795
Average Daily Posts0
|
Members2,174
Most Online1,567 Apr 25th, 2010
|
|
|
Okay WTF?
by HenryMiring on 09/27/17 08:45 AM
|
|
|
|
|
|
|
|