Previous Thread
Next Thread
Print Thread
Rate Thread
#17724 03/06/02 10:53 AM
Joined: Mar 2002
Posts: 9
G
Junior Member
OP Offline
Junior Member
G
Joined: Mar 2002
Posts: 9
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! smile

#17725 03/06/02 10:58 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Check out http://www.planetsourcecode.com/vb/...triesPerPage=10&blnResetAllVariables =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 11:05 AM
Joined: Mar 2002
Posts: 9
G
Junior Member
OP Offline
Junior Member
G
Joined: Mar 2002
Posts: 9
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.

laugh

#17727 03/06/02 11:08 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
lol glad i could be of service smile.


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17728 03/06/02 05:37 PM
Joined: Mar 2002
Posts: 9
G
Junior Member
OP Offline
Junior Member
G
Joined: Mar 2002
Posts: 9
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

#17729 03/06/02 05:50 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
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/06/02 05:54 PM
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
Offline
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
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/06/02 06:05 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
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/06/02 06:57 PM
Joined: Mar 2002
Posts: 9
G
Junior Member
OP Offline
Junior Member
G
Joined: Mar 2002
Posts: 9
I stand corrected, then.
Thank you very much. smile
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!

#17733 03/07/02 06:24 AM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
ms certifide 'eh? so you crash a lot?


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


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#17734 03/07/02 06:43 PM
Joined: Mar 2002
Posts: 256
Likes: 1
UGN Security Staff
Offline
UGN Security Staff
Joined: Mar 2002
Posts: 256
Likes: 1
'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/07/02 07:02 PM
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
Offline
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
/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 07:28 AM
Joined: Mar 2002
Posts: 9
G
Junior Member
OP Offline
Junior Member
G
Joined: Mar 2002
Posts: 9
Thanks Everyone, you've been a great help. smile


Link Copied to Clipboard
Member Spotlight
Posts: 30
Joined: June 2002
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Crime 1
Ice 1
Dartur 1
Cyrez 1
Powered by UBB.threads™ PHP Forum Software 7.7.5