I've written some code and it's setup so that one textbox displays the current date and time refreshed every second and a second textbox displays the difference between the current time and a set date. The clock refreshes correctly, but the time difference only updates every two seconds; I'm not sure if it's a flaw in my code or if it's just a lot of calculations to do in a second.
Suggestions?
VB.NET:
Private Sub Timer1_tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim today As Date = Now
days = (DateDiff(DateInterval.Second, start, today)) / 86400
While days >= 365
days = days - 365
years = years + 1
End While
If days > 1 Then
Day = Math.Floor(days)
End If
hours = (days - Day) * 24
Hour = Math.Floor(hours)
minutes = (hours - hour) * 60
Minute = Math.Floor(minutes)
seconds = (minutes - minute) * 60
Second = Math.Floor(seconds)
txtTime.Text = CStr(years) + " years " + CStr(day) _
+ " days " + CStr(hour) + " hours " + CStr(minute) + " minutes " + CStr(second) + " seconds "
txtNow.Text = CStr(today)
End Sub