Time span - negative value - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Time span - negative value


I need a help to calculate elapsed time (start time -end time).
I used the following code in windows apps. it's Working perfectly.

But, when i use the same in Pocket PC apps,getting some negative result.
I've tested it in Pocket PC Emulator.(VS2003)


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ck = DateTime.Now
Timer2.Enabled = True
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Timer2.Enabled = False
ck1 = DateTime.Now
ck3 = ck1.Subtract(ck)
Label5.Text = String.Format("{00:d2}:{01:d2}", ck3.Minutes, ck3.Seconds)
Timer2.Enabled = True
End Sub

Where Ck,ck1 are datetime variables.
Ck3 timespan variable.

Can anyone advice me to solve this?

Thank YOu!
Sign In or Register to comment.