Jo&#227&#59;o Duarte

Hello,
I want to know if it's possible to see the current value of the timer enable.
For example:
timer1.interval=100000
and before the timer1 stops i press a buton that shows me a msgbox with the current remaining time.
EX: 5000

Thanks


Re: Visual Basic Express Edition timer current value?

ReneeC

The interval is a property so:

Dim Interval as integer = tmr.interval ' will return your value.






Re: Visual Basic Express Edition timer current value?

João Duarte

i don't want to know the value of the interval.

I want to know the current value before the timer stops when reached the interval.

If the intervalies 10000, and i press the button and i want it shows me the actual value, for example, still remains half of time, the msgbx returns 5000.





Re: Visual Basic Express Edition timer current value?

João Duarte

i don't want to know the value of the interval.

I want to know the current value before the timer stops when reached the interval..

If the intervalies 10000, and i press the button and i want it shows me the actual value, for example, still remains half of time, the msgbx returns 5000.





Re: Visual Basic Express Edition timer current value?

nobugz

The Timer class doesn't let you find out how much is remaining. There are various solutions, here's one:

Public Class Form1
Private mTimerStart As Date
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = 10000
Timer1.Enabled = True
mTimerStart = Now
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Not Timer1.Enabled Then
Console.WriteLine("Timer not running")
Else
Dim diff As TimeSpan = Now - mTimerStart
Console.WriteLine("There are {0} milliseconds left", Timer1.Interval - diff.TotalMilliseconds)
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Console.WriteLine("Timer1 finished")
End Sub
End Class