Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am looking for a very simple code to do a countdown in a label.

 

I have a label on my form, a start, stop, reset buttons, and the TimerControl.

 

So all i need is the code to have the timer control display in the label a countdown that when start is clicked will start counting down from 20 mins.

 

:confused: can someone help me?

Posted

Hi Lanc1988,

 

Try This,

 

Set the Timers Interval Property to 1000 milliseconds.

Set the Timers Enabled Property to False.

 

 

Declare a Variable as,

 

Dim iMaxTime as Integer = 1200.

Dim iMinutes as Integer = 20.

 

In Start Buttons Click add Follwing Code:

 

Timer1.Enabled = True

 

In Stop Buttons Click add the following Code:

 

Timer1.Enabled = False

 

In Reset Buttons Click add the following Code:

 

iMaxTime = 1200

iMinutes = 20

Label1.Text = ""

 

In the Timers Event which will fire every 1 second add folowing code,

 

If iMaxTime>0 then

If IMaxTime Mod 60 = 0 then

Label1.Text = IMinutes

iMinutes-=1

End If

End IF

 

iMaxTime-=1

 

HOPE THIS WORKS OUT TRY IT!!!

 

GetYourAnswers

Posted

still doesn't update the time.. i have all of this in the Timer's code:

 

 

'Declare SkullTimer Variables

Dim iMaxTime As Integer = 1200

Dim iMinutes As Integer = 20

Dim iSeconds As Integer = 60

'Sets timer to countdown from 20 mins.

If iMaxTime > 0 Then

If IMaxTime Mod 60 = 0 Then

Application.DoEvents()

Label3.Text = iMinutes

iMinutes -= 1

End If

End If

 

iMaxTime -= 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...