+ Reply to Thread
Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43

Thread: CountDown timer Class in VB.Net

  1. #1
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    CountDown timer Class in VB.Net

    In a lot different programs I wrote countdown timers, in the end it became very boring and frustrating. I decided to make a countdown timer class. And so I did. I will upload it here so everyone who wants to use, will be able to use it.


    The class is made in a "professional way" and includes this:
    • Set the time with:
      • Timespan
      • Seconds
      • Minutes
      • Hours
      • Days
    • Add extra time with:
      • Timespan
      • Seconds
      • Minutes
      • Hours
      • Days
    • Start
    • Pause
    • Reset
    • Get the time left in:
      • Seconds
      • Minutes
      • Hours
      • Days
    • Return the number of:
      • Seconds
      • Minutes
      • Hours
      • Days
    • Event Each Second.
    • Event on times up.


    It is possible it will contains some bugs, let me know if you find any.



    Do you want to make your own class? Look here to see how.

    The class you'll find at the bottom.
    /Vswe


    UPDATED:
    • Removed the ability to use milliseconds, this is for avoiding lagging and delays when the event is raised once a millisecond(bad mistake of me), now the smallest value is seconds.
    • small Event bug fix
    Attached Files Attached Files
    Last edited by Vswe; 07-23-2009 at 02:24 AM.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: CountDown timer Class in VB.Net

    Very cool! I almost posted the code on ASCIIBin so people wouldn't have to download.
    Thanks for sharing and nice job linking back to your tutorial.

  4. #3
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: CountDown timer Class in VB.Net

    I thought it were better to put it in a .txt file rather then post it inside the code tags since it were pretty long. I'm Glad you liked it

  5. #4
    brettus is offline Newbie
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Re: CountDown timer Class in VB.Net

    excellent program!!

  6. #5
    jameslcs's Avatar
    jameslcs is offline Newbie
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0
    how to i use it as a class in VB? How to turn a .txt file into a class?

    oh ready know, open a VB project then add new item-> select class. -> delete text in class then,
    Copy n paste the text from the .txt file into the class.
    Rename the class to CountDown.vb
    Last edited by WingedPanther; 08-13-2009 at 02:15 PM. Reason: Double post

  7. #6
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: CountDown timer Class in VB.Net

    Quote Originally Posted by jameslcs View Post
    how to i use it as a class in VB? How to turn a .txt file into a class?

    oh ready know, open a VB project then add new item-> select class. -> delete text in class then,
    Copy n paste the text from the .txt file into the class.
    Rename the class to CountDown.vb
    I'm glad you get it working. The reason I didn't upload it as a .vb file was that CodeCall doesn't support the .vb extension for files.

  8. #7
    aiu4840 is offline Newbie
    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Re: CountDown timer Class in VB.Net

    Love it!

  9. #8
    zapman2003 is offline Newbie
    Join Date
    Aug 2009
    Posts
    1
    Rep Power
    0

    Re: CountDown timer Class in VB.Net

    I think the best things in life were invented out of boredom as opposed to necessity. Love it!

  10. #9
    jameslcs's Avatar
    jameslcs is offline Newbie
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Re: CountDown timer Class in VB.Net

    Hi, i kinda new in vb, i try to make it work but i can't get the timer running, may be i don't really understand the class much.

    can you provide some explanation how the class work. thanks

  11. #10
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: CountDown timer Class in VB.Net

    if you need more help, just tell me.


    Code:
        Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            'Declares a variable for our countdown timer.
            Dim Count As CountDown
    
            'Set the time to 3 minutes, this can be done in two ways
    
            '----way 1----
            Count = New CountDown(0, 3)
            '--------
    
    
            '----way 2----
            Count = New CountDown
            Count.SetTime(0, 3)
            '--------
    
            'If we want to add some more time we can do so, here I add 35 seconds.
            Count.AddTime(35)
    
            'add a handler to the tick event
            AddHandler Count.Tick, AddressOf Count_Tick
    
            'add a handler to the times up event
            AddHandler Count.TimesOut, AddressOf Times_up
    
    
            'starts the timer
            Count.Start()
    
            'It's also possible to pause and reset the timer.
            '   Count.Pause()
            '   Count.Reset()
        End Sub
    
    
        Private Sub Count_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
            'since we added the handler, this code will occur once each second
    
            'get the time left
            Me.Text = sender.Days & " days, " & sender.Hours & " hours, " & sender.Minutes & " minutes and " & sender.Seconds & " seconds left."
    
            'it's alo possible to use Totalseconds, totalminutes etc. 
            'This will return the total amount of them. 
            'For example if we got the time 1 minute and 30 seconds
            'TotalSeconds will return 90 and Totalminutes will return 1.5.
        End Sub
    
        Private Sub Times_up(ByVal sender As System.Object, ByVal e As System.EventArgs)
            'when the time us up this will happen
    
            MessageBox.Show("Wake up!!!")
        End Sub

+ Reply to Thread
Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. C# and WPF countdown timer
    By Jrb in forum C# Programming
    Replies: 1
    Last Post: 10-11-2011, 12:47 PM
  2. Need help with Countdown timer
    By Myvision in forum JavaScript and CSS
    Replies: 3
    Last Post: 04-29-2011, 10:31 AM
  3. javascript countdown timer
    By theonebeyond in forum JavaScript and CSS
    Replies: 2
    Last Post: 02-07-2011, 07:08 AM
  4. Interactive Batch Countdown Timer
    By dscheive in forum General Programming
    Replies: 1
    Last Post: 09-23-2009, 10:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts