Private Sub countDown(seconds As Int)
Dim startTime As Long = DateTime.Now
Dim countDownEnabled As Boolean = True
Dim remainingTime As Int
Dim minutes As Int
Dim secs As Int
Do While countDownEnabled
Dim count As Int = (DateTime.Now - startTime) / 1000
If count >= seconds Then
countDownEnabled = False ' disable timer when time is up
Else
remainingTime = seconds - count
minutes = remainingTime / 60
secs = remainingTime Mod 60
'Display the time in mm:ss format
Button2.Text = $"${NumberFormat2(minutes, 2, 0, 0, False)}:${NumberFormat2(secs, 2, 0, 0, False)}"$
End If
Sleep(1000) ' pause for a second
Loop
End Sub