Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#17724 - 03/06/02 05:53 PM VB countdown timer  
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis Offline
Junior Member
Geek_Goddess_IISis  Offline
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.]=-
Sponsored Links
#17725 - 03/06/02 05:58 PM Re: VB countdown timer  
Joined: Feb 2002
Posts: 7,195
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,195
Likes: 3
Portland, OR; USA
Check out http://www.planetsourcecode.com/vb/scrip...setAllVariables =TRUE&txtCriteria=countdown&optSort=Alphabetical

it'll have a grip of results, we use them at times to look through and view how diff things are done.


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17726 - 03/06/02 06:05 PM Re: VB countdown timer  
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis Offline
Junior Member
Geek_Goddess_IISis  Offline
Junior Member

Joined: Mar 2002
Posts: 9
Ohio
Many Thanks! Gismo, I saw a couple things that look like they will do the trick. Will let you know what my code diving adventures surface tonight.



-=[Do Not tap on the glass. Do Not feed the geeks. They are on a strict diet of caffeine and no sleep.]=-
#17727 - 03/06/02 06:08 PM Re: VB countdown timer  
Joined: Feb 2002
Posts: 7,195
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,195
Likes: 3
Portland, OR; USA
lol glad i could be of service :).


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17728 - 03/07/02 12:37 AM Re: VB countdown timer  
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis Offline
Junior Member
Geek_Goddess_IISis  Offline
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.]=-
Sponsored Links
#17729 - 03/07/02 12:50 AM Re: VB countdown timer  
Joined: Feb 2002
Posts: 7,195
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,195
Likes: 3
Portland, OR; USA
woudlnt it be more practicle to use a dll and have it save a date/time to count down to?


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17730 - 03/07/02 12:54 AM Re: VB countdown timer  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
I'm really big on efficiency and accuracy, so here's my anal response. Your code is 1 hour and 1 minute off. To see for yourself, set the TgtDate to the next day and do a little math. Here's your corrected and much more efficient code:

Private Sub Timer1_Timer()
Dim TgtDate As Date

'Change TgtDate to whatever date you want to count down to.
TgtDate = #3/7/2002#

Label1 = DateDiff("d", Now() + 1, TgtDate) & " Days " & Format(TgtDate - Now(), "hh:nn:ss")
End Sub


Domain Registration, Hosting, Management
http://www.dollardns.net
#17731 - 03/07/02 01:05 AM Re: VB countdown timer  
Joined: Feb 2002
Posts: 7,195
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,195
Likes: 3
Portland, OR; USA
see thats why i love him lol


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17732 - 03/07/02 01:57 AM Re: VB countdown timer  
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis Offline
Junior Member
Geek_Goddess_IISis  Offline
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.]=-
#17733 - 03/07/02 01:24 PM Re: VB countdown timer  
Joined: Feb 2002
Posts: 7,195
Gremelin Offline
Community Owner
Gremelin  Offline

Community Owner

Joined: Feb 2002
Posts: 7,195
Likes: 3
Portland, OR; USA
ms certifide 'eh? so you crash a lot?


heh my cusin wrote the Server 2 course book, beat that


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Sponsored Links
#17734 - 03/08/02 01:43 AM Re: VB countdown timer  
Joined: Mar 2002
Posts: 256
ninjaneo Offline
UGN Security Staff
ninjaneo  Offline
UGN Security Staff

Joined: Mar 2002
Posts: 256
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

#17735 - 03/08/02 02:02 AM Re: VB countdown timer  
Joined: Mar 2002
Posts: 1,273
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
/me points to neo's code

He's a commendable programmer, but HIS stuff IS along Microsoft quality.

Here's a minor fix. The days count was the only piece of the original code that I didn't modify - cause I thought it worked. But it didn't when I tested adding a time. So here's the fixed code:

Private Sub Timer1_Timer()
Dim TgtDate As Date

'Change TgtDate to whatever date you want to count down to.
TgtDate = #3/8/2002 12:00:00 PM#

Label1 = DateDiff("d", Now(), TgtDate) - 1 & " Days " & Format(TgtDate - Now(), "hh:nn:ss")
End Sub


Domain Registration, Hosting, Management
http://www.dollardns.net
#17736 - 03/08/02 02:28 PM Re: VB countdown timer  
Joined: Mar 2002
Posts: 9
Geek_Goddess_IISis Offline
Junior Member
Geek_Goddess_IISis  Offline
Junior Member

Joined: Mar 2002
Posts: 9
Ohio
Thanks Everyone, you've been a great help.


-=[Do Not tap on the glass. Do Not feed the geeks. They are on a strict diet of caffeine and no sleep.]=-

Member Spotlight
Gremelin
Gremelin
Portland, OR; USA
Posts: 7,195
Joined: February 2002
Show All Member Profiles 
Forum Statistics
Forums45
Topics46,816
Posts81,986
Average Daily Posts11
Members2,159
Most Online1,567
Apr 25th, 2010
Latest Postings
Top Posters(All Time)
UGN Security 39,980
Gremelin 7,195
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
Ghost Likes: 1
Gremelin Likes: 4
Ice Likes: 1
unreal Likes: 1
Top Liked Users (30 Days)
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20160902)