Results 1 to 10 of 10

Thread: Timer Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184
    I have a problem with my timer
    all a sudden not working.
    It wont run through the code
    and it is still enabled, I
    changed.
    Why??
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb

    May be you can post your code and let us have look on what you did?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184
    impossable.

    11 timers, 20 forms.. 20 modules..

    its a 12 meg program.
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb Too Many Timer

    Why you need so many Timer? Most properly, I think is before others Timer is executing some dedicated code under it Timerx_Timer() events.

    If you really need so many Timer in your program, Then you may need to revise all your Timer interval. Try to have a proper time slot for each Timer. Make sure they don't overlapp each others.

    But the best still try to remove some Timer.

  5. #5
    Addicted Member LAURENS's Avatar
    Join Date
    Jan 2000
    Location
    Utrecht, the Netherlands
    Posts
    138

    One timer is enough

    You shouldn't use so many timers. I once read somewhere that windows can only take a limited amount of timers but I forgot why and how many.
    You can do with 1 per project and derive different intervals from this one.

    All the code can be in one timer event then.



    [Edited by LAURENS on 06-16-2000 at 10:38 AM]
    Regards,
    Laurens

    Using VB5 Enterprise edition SP3
    VB6 Enterprise edition SP5

  6. #6
    New Member
    Join Date
    May 2000
    Posts
    13

    program

    What's your program supposed to do?

    Osborn

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184
    Its a 3d game.
    I cant get around the
    timers.
    What else could I use like a timer?
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  8. #8
    Guest
    Use the GetTickCount API.

  9. #9
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Make sure that the timer's value isn't set to 0 because if it is, it woun't work

  10. #10
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    SetTimer + KillTimer

    If your game does not require a high accuratecy timer, then may be you can use the SetTimer and KiiTimer as shown below:

    Code:
    'Code under Basic Module
    Option Explicit
    Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    
    Public Sub load_SetTimer(ByVal MyhWnd As Long, ByVal MyInterval As Long)
        SetTimer MyhWnd, 0, MyInterval, AddressOf TimerProc
    End Sub
    
    Sub TimerProc(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long)
       Do what ever your game needed here.
    End Sub
    
    Public Sub load_KillTimer()
         KillTimer frmMain.hwnd, 0
    End Sub
    
    'Code under Form Assume your form is named frmMain.frm
    Private Sub Form_Load()
        'Timer with interval 60Seconds
        load_SetTimer Me.hWnd, 60000 
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        'Reset the Timer upon exit the games
        load_KillTimer 
    End Sub


    [Edited by Chris on 06-17-2000 at 03:13 PM]

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