If a timer is set to go off 10000 milliseconds (10 seconds), how can i display how much time is left before its executed?
If a timer is set to go off 10000 milliseconds (10 seconds), how can i display how much time is left before its executed?
Instead of setting the interval to 10000, set it to 1000 (1 second) and use a static variable to count how many seconds it's been. This example requires a timer (Timer1) and a label (Label1):
VB Code:
Private Sub Form_Load() Timer1.Interval = 1000 Label1.Caption = "10 seconds remaining." End Sub Private Sub Timer1_Timer() Static num As Integer num = num + 1 If num = 10 Then 'do your stuff here MsgBox "10 seconds is up" num = 1 Label1.Caption = 10 Else Label1.Caption = 10 - num & " seconds remaining." End If End Sub