If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Countdown timer help....

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-05, 11:31
Daniel_Johns Daniel_Johns is offline
Registered User
 
Join Date: Jul 2004
Posts: 69
Countdown timer help....

hi guys! i want to create a 'simple' countdown timer (from 30 - 0 secs.) in excel. any code to share? (this is an easy job in vb using timer control but i cant find it in excel vb...)

objects in userform:
- Label1 (in which the countdown is shown)
- CommandButton (if pressed, starts the countdown)

thnx in advance...
Reply With Quote
  #2 (permalink)  
Old 02-23-05, 11:49
DavidCoutts DavidCoutts is offline
Registered User
 
Join Date: Jan 2004
Location: Aberdeen, Scotland
Posts: 1,067
Ok 2 things needed here

firstly in your Class module where your Controls reside
Code:
Private Sub cmdStart_Click()
    lblTime.Caption = 30
    StartTimer
End Sub
and in a module

Code:
Public Sub StartTimer()
    Application.OnTime DateAdd("s", 1, Now), "RunTimer"
End Sub

Public Sub RunTimer()
    Worksheets("sheet1").lblTime.Caption = CInt(Worksheets("sheet1").lblTime.Caption) - 1
    If Worksheets("sheet1").lblTime.Caption > 0 Then StartTimer
End Sub
this should do what you need from it
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On