It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Timer code help please!

Moderator: dafunkymunky

Timer code help please!

Postby El Don on Thu Mar 05, 2009 7:39 pm

I'm trying to program a countdown timer that shows the time in a label, with a button to start it, and if the button is pressed again add certain amount of time, for example 1 minute. Can anyone help me please? I need it for my biology class.
El Don
 
Posts: 2
Joined: Thu Mar 05, 2009 7:21 pm

Re: Timer code help please!

Postby White95dp on Mon Mar 09, 2009 1:07 am

Dim iClock As Integer

Private Sub Command1_Click()
If Timer1.Enabled Then
iClock = iClock + 60
Else
Timer1.Enabled = True
Label1.Caption = "0:00"
End If

End Sub

Private Sub Form_Load()
iClock = 0
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
Dim iMin As Integer
Dim iSec As Integer
iClock = iClock + 1
iMin = Int(iClock / 60)
iSec = iClock - iMin * 60
Label1.Caption = iMin & ":" & Format(iSec, "00")
End Sub
White95dp
 
Posts: 7
Joined: Mon Mar 09, 2009 12:52 am


Who is online

Users browsing this forum: No registered users and 5 guests