Results 1 to 9 of 9

Thread: Big Help Needed (Too much code)

  1. #1

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284

    Question Big Help Needed (Too much code)

    I have a problem. I have a timer that runs at full speed all the time. It has a million things in it. Basicly if checks a bunch of menus to see of there checked or not, and if one is checked then it runs a function or sub. The only thing is that this timer does soo much, and runs through so many subs and functions it interfears with running other timers. I have slower timers freez on me. I KNOW FOR A FACT That my other timers never get turned off, they just freez. Now.... For my question...
    I'm thinking I need a way to make this timer alone in a differnt project or a dll file, or 2nd project, or something. I need it appart from my project but i need it to interact with my project at high speed. What can I do? Is there anything at all??
    ~* )v( ! /< E *~

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What is it you are doing? Wouldn't it be easier to use the check or menu events to know when they change?

  3. #3

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284
    no no.. It hads to be constant.. Its like.. Kill stuff.. kill advertisements if they show up.. kill this window if it opens..click this button on this window if that window is showing. But it’s coded like if TheMenu.killADwindow.checked = true then Call (KillAdvertisements). Then if an advertisement window is showing then it kills it. So it kind of waits for the window, so the timer has to be continuously running. Now that’s just one example.
    Does that make any since?
    ~* )v( ! /< E *~

  4. #4

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284
    HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!
    PLEASE!! SOME ONE HLEP ME!!!
    ~* )v( ! /< E *~

  5. #5
    Hyperactive Member Libero's Avatar
    Join Date
    Jun 2000
    Location
    Swedish viking
    Posts
    460
    Cant u use:

    Private Sub Check1_Click()

    If check1.value = 1 then
    ' your code
    end if
    End Sub

  6. #6

    Thread Starter
    Hyperactive Member MikeBAM's Avatar
    Join Date
    Sep 2000
    Location
    Metro Detroit
    Posts
    284
    nah man! read the 3rd post.. what is my 2nd post up on the page.
    ~* )v( ! /< E *~

  7. #7
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    I like a qtn where the word 'kill' is used a lot!
    Ok, so let me get this straight. A timer checks to see something happens. If it does it goes and does lots of code. But, meantime other timers (and this timer i presume) are still working. The timers are freezing cos it is all too much to cope with?

    Assuming i understand that correctly... Say if Timer1 detects an event happening. Can u then turn off all other timers, process ur intensive code and then turn them back on again?

    If there is a chance of something happening during ur intensive code then can u add doevents during that code and do a minimalist check for new events occurring and say set a boolean flag. So, when u get to the end of ur intensive code it could check if there is something more to do. Finally, the code would reset the timers.enabled to true and keep going.

    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

  8. #8
    Addicted Member
    Join Date
    Jul 1999
    Location
    Ottawa
    Posts
    155
    You should use

    DOEVENTS keyword

    in any LOOP that you have, this way OTHER times can work at the same time.

    for example:

    for A=1 to 10


    msgbox "Hay Mr. DJ!"

    call timer2_timer()

    doevents

    next A

  9. #9
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Smile Timer callbacks... Performance increase...

    Use a Timer callback instead of lots of timers. It may add some performance increase. i.e.
    VB Code:
    1. 'Coded by Digital-X-Treme, 2001. VB-Forums.
    2.  
    3. 'In a module.
    4. Option Explicit
    5.  
    6. Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    7. Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
    8.  
    9. Public m_Hwnd As Long
    10.  
    11. Public Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, _
    12.                         ByVal dwTime As Long)
    13.  
    14.     Select Case idEvent
    15.        
    16.         Case 1
    17.             'Call Timer1_Code...
    18.         Case 2
    19.             'Call Timer2_Code...
    20.         Case 3
    21.             'Call Timer3_Code...
    22.         Case 4
    23.             'Call Timer4_Code...
    24.         Case 5
    25.             'Call Timer5_Code...
    26.     End Select
    27.    
    28. End Sub
    29.  
    30. Public Sub Kill_Timer(ByVal ID As Long)
    31.     KillTimer m_Hwnd, ID
    32. End Sub
    33.  
    34. Public Sub Set_Timer(ByVal ID As Long, ByVal Milliseconds As Long)
    35.     SetTimer m_Hwnd, ID, Milliseconds, AddressOf TimerProc
    36. End Sub
    37.  
    38.  
    39. 'In a form etc.
    40. m_Hwnd = Form1.Hwnd
    41. 'Set timers.
    42. Call Set_Timer(1, 1000) 'Create a timer with ID: 1, interal 1 second.
    43. Call Set_Timer(2, 3000) 'Create a timer with ID: 2, interal 3 seconds.
    44. Call Set_Timer(3, 6000) 'Create a timer with ID: 3, interal 6 seconds.
    45.  
    46. 'Kill timers.
    47. Call Kill_Timer(1)
    48. Call Kill_Timer(2)
    49. Call Kill_Timer(3)

    Hope this helps.
    Laterz
    Digital-X-Treme
    Contact me on MSN Messenger: [email protected]

    [VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
    / (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]

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