Results 1 to 2 of 2

Thread: Timer control substitute

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    101
    Ambivalentiowa,
    i think i can't use a loop because i need to be able to perform something else (like click a button...) while my timer perform another task. i am not allowed to use a timer control..is there another way?.

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    You could try an API timer.

    In a module
    VB Code:
    1. Option Explicit
    2.  
    3. Public Declare Function SetTimer Lib "user32" _
    4.         (ByVal hwnd As Long, ByVal nIDEvent As Long, _
    5.         ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    6. Public Declare Function KillTimer Lib "user32" _
    7.         (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    8.  
    9. Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    10.     MsgBox "place your timer code here"
    11. End Sub

    In your form
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     '   create the timer
    5.     '   The third parameter is the intervals in milliseconds
    6.     SetTimer Me.hwnd, 1, 10000, AddressOf TimerProc
    7. End Sub
    8.  
    9. Private Sub Form_Unload(Cancel As Integer)
    10.     '   Stop the timer
    11.     KillTimer Me.hwnd, 1
    12. End Sub
    Since the interval property is a long, you can run your timer for about 50 days.

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