Results 1 to 7 of 7

Thread: Why wont it stop

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80

    Why wont it stop

    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

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Try T => 5 (equal to OR greater than 5)

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Problem here to:
    VB Code:
    1. If T = 1 Or 2 Or 3 Or 4 Then

    should be:
    VB Code:
    1. If T = 1 Or T = 2 Or T= 3 Or T = 4 Then


    And......... You prolly need atleast MOD 6 too.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    Nope, didn't work.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    Ah dang "or" stuff... I always mess it up.

    Although it still doesnt shut down.

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    I successfully tested with this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.    Timer1.Interval = 1000
    5.    Timer1.Enabled = True
    6. End Sub
    7. Private Sub timer1_Timer()
    8. Dim T As Integer
    9. T = Second(Now) Mod 6
    10.  
    11. If T = 1 Or T = 2 Or T = 3 Or T = 4 Then
    12. 'MoveShrap
    13. ElseIf T >= 5 Then
    14. MsgBox "Greater Than 5"
    15. 'ShrapTime.Enabled = False
    16. End If
    17.  
    18. End Sub

  7. #7
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    And... you can replace that whole T= LINE with:
    VB Code:
    1. If T <= 4 Then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width