Results 1 to 5 of 5

Thread: 10 minute timer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2002
    Location
    Kitchener, Ontario
    Posts
    22

    Question 10 minute timer

    Hello

    I am in need of some big help to be able to set a timer interval (an event) to occur every 10 minutes. The current timer controls only allow 65000ms. So I have the usualy code for the timer interval set:

    tmrtimer.Interval = gettimerdef
    tmrtimer.Enabled = True

    where gettimerdef is defined by a value from a textbox.

    I would like to wrap this somehow so that it only occurs every 10 minutes. Any suggestions will be greatly appreciated.

    Rob
    Thanks for the help !

    RobJ

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    set the timer to 60000 which is 1 minute and use a static variable in the timer event to incriment it until it = 10... something like
    VB Code:
    1. Private Sub Timer1_Timer
    2.     Static iCount as Integer
    3.     if iCount = 10 then
    4.         iCount = 0
    5.         'YOUR CODE HERE
    6.     else
    7.         iCount = iCount + 1
    8.     end if
    9. End Sub

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Alternatively, you can use the Timer API :
    VB Code:
    1. 'in a form
    2. Option Explicit
    3.  
    4. Private Sub Form_Load()
    5.     'Create an API-timer
    6.     SetTimer Me.hwnd, 0, 600000, AddressOf TimerProc
    7. End Sub
    8.  
    9. Private Sub Form_Unload(Cancel As Integer)
    10.     'Kill our API-timer
    11.     KillTimer Me.hwnd, 0
    12. End Sub
    13.  
    14.  
    15.  
    16. 'in a module
    17. Option Explicit
    18.  
    19. Public Declare Function SetTimer Lib "user32" _
    20. (ByVal hwnd As Long, ByVal nIDEvent As Long, _
    21. ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    22.  
    23. Public Declare Function KillTimer Lib "user32" _
    24. (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    25.  
    26. Public Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
    27.     MsgBox "hello world"
    28. End Sub
    Last edited by amitabh; Dec 30th, 2002 at 10:14 AM.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Try experimenting with this.
    Attached Files Attached Files


    Has someone helped you? Then you can Rate their helpful post.

  5. #5
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    VB Code:
    1. Private Sub Form_Load() 'Or whatever event will begin the timing
    2. Text1.Text = Now()
    3. End Sub
    4.  
    5. Private Sub Timer1_Timer()
    6. Timer1.Interval = 1000
    7. TenMinutes = DateDiff("n", Text1, Now())
    8.  
    9.     If TenMinutes = 10 Then
    10.         'Do Something
    11.         'Then reset Text1 to the new Now()
    12.     Else
    13.         'Don't Do Something
    14.     End If
    15.  
    16. End Sub
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

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