+ Reply to Thread
Page 1 of 3
1 2 3 LastLast
Results 1 to 10 of 29

Thread: CountDown timer Class in VB.Net

  1. #1
    Moderator Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe's Avatar
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Age
    16
    Posts
    8,819
    Blog Entries
    5

    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
    Last edited by Vswe; 07-23-2009 at 04:24 AM.

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    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.

  3. #3
    Moderator Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe's Avatar
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Age
    16
    Posts
    8,819
    Blog Entries
    5

    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

  4. #4
    Newbie brettus is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    1

    Re: CountDown timer Class in VB.Net

    excellent program!!

  5. #5
    Newbie jameslcs is an unknown quantity at this point jameslcs's Avatar
    Join Date
    Aug 2009
    Posts
    7
    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 04:15 PM. Reason: Double post

  6. #6
    Moderator Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe's Avatar
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Age
    16
    Posts
    8,819
    Blog Entries
    5

    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.

  7. #7
    Newbie aiu4840 is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    1

    Re: CountDown timer Class in VB.Net

    Love it!

  8. #8
    Newbie zapman2003 is an unknown quantity at this point
    Join Date
    Aug 2009
    Posts
    1

    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!

  9. #9
    Newbie jameslcs is an unknown quantity at this point jameslcs's Avatar
    Join Date
    Aug 2009
    Posts
    7

    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

  10. #10
    Moderator Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe has a reputation beyond repute Vswe's Avatar
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Age
    16
    Posts
    8,819
    Blog Entries
    5

    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 3
1 2 3 LastLast

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Tutorial: Starting C# with C# 2008 Express Edition
    By Jordan in forum CSharp Tutorials
    Replies: 20
    Last Post: 07-27-2009, 04:45 AM
  2. Classes in VB.NET
    By Vswe in forum VB Tutorials
    Replies: 1
    Last Post: 07-21-2009, 12:18 PM
  3. PHP Objects
    By chili5 in forum PHP Tutorials
    Replies: 5
    Last Post: 03-24-2009, 05:12 PM
  4. PHP 5 and OOP
    By Jordan in forum PHP Tutorials
    Replies: 11
    Last Post: 09-22-2008, 01:58 AM
  5. Joomla! Tutorial #3: CSS Class Suffix
    By takercena in forum Tutorials
    Replies: 1
    Last Post: 03-14-2008, 01:51 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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