Sub Button1_Click
Wait For (GetDateTodayOn) Complete (Ticks As Long)
Log($"Selected date: $Date{Ticks}"$)
End Sub
Private Sub GetDateTodayOn As ResumableSub
Do While True
Wait For (dialog.ShowTemplate(DateTemplate, "", "", "Cancel")) Complete (Result As Int)
Dim zero As Long = 0
If Result = xui.DialogResponse_Cancel Then Return zero
Dim days As Int = DateUtils.PeriodBetweenInDays(DateTime.Now, DateTemplate.Date).Days
If days < 0 Then
DateTemplate.Date = DateTime.Now
Wait For (dialog.Show("Invalid date", "Ok", "", "")) Complete (Result As Int)
Else
Return DateTemplate.Date
End If
Loop
Return 0
End Sub