CountDown Timer Label

Code Snippet

Dim CountDownAsInteger = 0

Dim TimeSelectionAsLong

PrivateSub AutoCopyTimer_Tick(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles AutoCopyTimer.Tick

Dim TimeAsDouble = TimeSelection * 60

CountDown += 1

If CountDown = TimeThen

MsgBox("test")

'Call Copy Procedure

Else

TimerLabel.Text = Format(Time - CountDown,"HH:mm:ss")

EndIf

EndSub

PrivateSub AutoCopyTimerForm_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

SetTimerMins()

'TimerLabel.Text = TimeSelection

AutoCopyTimer.Enabled =True

EndSub

PrivateSub SetTimerMins()

SelectCase mgmtoptdialog.AutoCopyInterval.Text

Case"Every 15 Minutes"

TimeSelection = 15

Case"Every 30 Minutes"

TimeSelection = 30

Case"Every 45 Minutes"

TimeSelection = 45

Case"Every 60 Minutes"

TimeSelection = 60

Case"Every 90 Minutes"

TimeSelection = 90

Case"Every 120 Minutes"

TimeSelection = 120

EndSelect

EndSub

I'm working on a countdown timer based on the selection of text from a combobox.

It work half way since when the ticking starts my label displays hh:mmTongue Tieds and I cannot see the countdown.

What am I doing wrong?

I thought I had it.

[5136 byte] By [wayliff] at [2008-1-3]
# 1

You could replace :

TimerLabel.Text = Format(Time - CountDown, "HH:mmTongue Tieds")

with

Code Snippet

Dim ts As TimeSpan = TimeSpan.FromSeconds(Time - CountDown)

TimerLabel1.Text = getTimeString(ts)

and add the following function :

Code Snippet

Private Function getTimeString(ByVal ts As TimeSpan) As String

Return (ts.Hours.ToString("00") + ":" + ts.Minutes.ToString("00") _

+ ":" + ts.Seconds.ToString("00"))

End Function

ArranNyc at 2007-9-25 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

yes indeedthanks for your help.

That made my morning.

wayliff at 2007-9-25 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
or you could have simply used maths to find the time in hour min sec
JPC16 at 2007-9-25 > top of Msdn Tech,Visual Basic,Visual Basic General...