Results 1 to 4 of 4

Thread: [RESOLVED] Countdown Timer

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Resolved [RESOLVED] Countdown Timer

    Hi

    Is it possible or in VB to make a countdown timer that the user could see that would display time counting down for eg. 5 sec to 0 sec.


    Thanks

  2. #2
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Countdown Timer

    Quote Originally Posted by homer5677 View Post
    Hi

    Is it possible or in VB to make a countdown timer that the user could see that would display time counting down for eg. 5 sec to 0 sec.

    Thanks
    Yes, it is. Do you need to see code?
    Doctor Ed

  3. #3
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Countdown Timer

    Looks like you do. Build a form with a timer control and a label. Then apply this code:
    Code:
    Dim TimeSec As Integer
    Private Sub Form_Load()
    Timer1.Interval = 1000
    Label1.Caption = 10 ' Set this to the starting time in seconds.
    End Sub
    
    Private Sub Timer1_Timer()
    TimeSec = CInt(Label1.Caption)
    If TimeSec < 1 Then MsgBox "Time is up." Else Label1.Caption = Trim(TimeSec - 1)
    End Sub
    WDYT?
    Doctor Ed

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2011
    Posts
    60

    Re: Countdown Timer

    Thanks doc. I wasn't sure if VB was able to or if i needed something more powerful

Posting Permissions

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



Click Here to Expand Forum to Full Width