Why wont my timer turn off after it hits 5 seconds:
Private Sub ShrapTime_Timer()
Dim T As Integer
T = Second(Now) Mod 5
If T = 1 Or 2 Or 3 Or 4 Then
MoveShrap
ElseIf T = 5 Then
ShrapTime.Enabled = False
End If
End Sub
Printable View
Why wont my timer turn off after it hits 5 seconds:
Private Sub ShrapTime_Timer()
Dim T As Integer
T = Second(Now) Mod 5
If T = 1 Or 2 Or 3 Or 4 Then
MoveShrap
ElseIf T = 5 Then
ShrapTime.Enabled = False
End If
End Sub
Try T => 5 (equal to OR greater than 5)
Problem here to:
VB Code:
If T = 1 Or 2 Or 3 Or 4 Then
should be:
VB Code:
If T = 1 Or T = 2 Or T= 3 Or T = 4 Then
And......... You prolly need atleast MOD 6 too.
Nope, didn't work.
Ah dang "or" stuff... I always mess it up.
Although it still doesnt shut down.
I successfully tested with this:
VB Code:
Option Explicit Private Sub Form_Load() Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub timer1_Timer() Dim T As Integer T = Second(Now) Mod 6 If T = 1 Or T = 2 Or T = 3 Or T = 4 Then 'MoveShrap ElseIf T >= 5 Then MsgBox "Greater Than 5" 'ShrapTime.Enabled = False End If End Sub
And... you can replace that whole T= LINE with:
VB Code:
If T <= 4 Then