I’m creating an onscreen digital clock which I want to refresh every 1 second. I’me using the Datetime method to get the current time (& date) and putting the result in a Label.
This works ok and displays the time when I run the code. But I can’t get the code to refresh.
Coming most recently from Python, I think a While True … Wend loop would do this, but I can’t get it to work. I’ve tried this loop in the Opening method of the time display label, but it never displays the clock and hangs.
Current code:
'While True
Var d As DateTime = DateTime.Now
Var Hrint as integer = d.Hour
Var minint As integer = d.minute
Var secint As integer = d.second
Var Hr as String
Var min as String
Var sec as String
if Hrint < 10 then
Hr = "0" + str(Hrint)
Else
Hr = str(Hrint)
end if
if minint < 10 then
min = "0" + str(minint)
Else
min = str(minint)
end if
if secint < 10 then
sec = "0" + str(secint)
Else
sec = str(secint)
end if
TimeDisplay.Text = str(Hr) + ":" + str(Min) + ":" + str(sec)
' Wend
Sorry - I can’t find how to format the code!
Can anyone please help & point me in the right direction?