Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Timer Use

AyubaAyuba Posts: 1Member
Thank you very much for the membership upportunity you granted me.
Please, I want someone to help me on how to use the Timer to cause 4 Geometrical cycles(for example) to disappear and re-appear alternatively.

Comments

  • GenjuroGenjuro Posts: 913Member
    : Thank you very much for the membership upportunity you granted me.
    : Please, I want someone to help me on how to use the Timer to cause 4 Geometrical cycles(for example) to disappear and re-appear alternatively.
    :

    In VB6, "enabled" timers trigger a "Timer" event at anytime a specific time lapse ("interval") has expired (well... more or less; they have a minimum precision of 10-15 ms, which may or may not be acceptable... oh, well).
    This means that you just have to put a Timer on a Form, toy a little with its properties, and you'll be given a Timer1_Timer Subroutine which will be called "once in a given while".

    Now for this subroutine. You will need to keep track of the "currently displayed" geometrical cycle, which you should take care of with a Private Integer variable declared at Form scope (which means, in the "declarations" section of a form), and update it accordingly:

    [code]
    private CurrentCycle as integer

    Function DrawCycle()
    ' we'll see this later.
    End function

    Sub Timer1_Timer
    CurrentCycle = CurrentCycle + 1
    if CurrentCycle = 4 then CurrentCycle = 0
    Call DrawCycle()
    End Sub
    [/code]

    At every call of the Timer event handler, we modify our CurrentCycle adding 1 to it; if it ever reaches the value of 4, then we reset it to zero, so its value can only be 0, 1, 2, or 3.
    Then we call the DrawCycle function, which will draw a geometrical cycle. Since this function is also part of the Form, then it will be able to see the correct content of the "CurrentCycle" variable, and draw the right things onscreen.

    About drawing, I won't tell much as I am not sure about what you want to draw and how, but feel free to ask.
Sign In or Register to comment.