Results 1 to 9 of 9

Thread: Using the Timer_New To it

  1. #1

    Thread Starter
    Member cramtheman's Avatar
    Join Date
    Dec 2000
    Posts
    43

    Lightbulb

    I would like to animate something(this is not the problem) I want it to animate it after a cmd button is clicked. How do I get the animation code in the timer sub to animate when a cmd button is clicked. Can I put the animation code directly in the cmd button and some how make the timer know that this code is for it?

    Help would be much appriciated,
    Thanks,
    Marc
    cram
    [email protected]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Things to Ponder

    |Man who stands on toilet,
    Is high On pot|
    |Baseball Wrong,
    Man with four balls cannot walk|

  2. #2
    Hyperactive Member Jareware's Avatar
    Join Date
    Nov 2000
    Location
    Silicon Valley, CA
    Posts
    275
    Unless I understood the problem somehow wrong, just set the timers enabled value to false, and in the button code put:

    Timer1.Enabled = 1

    Then put the animation code to the timer and remember to set the interval.


    -JR-

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Just Enable the Timer

    Code:
    Sub Command1_Click()
    Timer1.Interval = 1000 'every second
    Timer1.Enabled = True 'activate
    'now the timer'll start activating the animation.
    End Sub
    Anyway, you could also loop it, just a matter of preference.

    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Hyperactive Member Jareware's Avatar
    Join Date
    Nov 2000
    Location
    Silicon Valley, CA
    Posts
    275
    Actually I told to first (in design) set the timer1.enabled to false so it doesn't start doing the animation stuff right when the prog starts.


    -JR-

  5. #5

    Thread Starter
    Member cramtheman's Avatar
    Join Date
    Dec 2000
    Posts
    43
    But my prob is that I want the animation to start only when a cmd button is clicked this is what the code looks like:

    Private Sub cmdSpin_Click()


    Timer1.Enabled = 1
    If (imgBlur.Left = 4200) And _
    (imgBlur.Top > 3120) Then
    imgBlur.Left = imgBlur.Left + 0
    imgBlur.Top = imgBlur.Top - 50
    Else
    imgBlur.Left = 2880
    imgBlur.Top = 4200
    End If
    End Sub

    Is this right or what is wrong, how can I get the animation to go when the button is clicked

    Thanks a bunch,
    Marc
    cram
    [email protected]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Things to Ponder

    |Man who stands on toilet,
    Is high On pot|
    |Baseball Wrong,
    Man with four balls cannot walk|

  6. #6
    Guest
    Maybe this thread will help you a little with your animation?

  7. #7

    Thread Starter
    Member cramtheman's Avatar
    Join Date
    Dec 2000
    Posts
    43

    Sleep 1

    What is the "sleep 1" mean?
    cram
    [email protected]
    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Things to Ponder

    |Man who stands on toilet,
    Is high On pot|
    |Baseball Wrong,
    Man with four balls cannot walk|

  8. #8
    Hyperactive Member theman32x's Avatar
    Join Date
    May 2000
    Location
    New Jersey, USA
    Posts
    305
    Timer1.Enabled = 1
    If (imgBlur.Left = 4200) And _
    (imgBlur.Top > 3120) Then
    imgBlur.Left = imgBlur.Left + 0
    imgBlur.Top = imgBlur.Top - 50
    Else
    imgBlur.Left = 2880
    imgBlur.Top = 4200
    End If
    End Sub

    in the command button put :
    timer1.enabled = true

    in the timer event put :
    If (imgBlur.Left = 4200) And _
    (imgBlur.Top > 3120) Then
    imgBlur.Left = imgBlur.Left + 0
    imgBlur.Top = imgBlur.Top - 50
    Else
    imgBlur.Left = 2880
    imgBlur.Top = 4200
    End If
    End Sub

  9. #9
    Guest
    sleep 1 slows the animation down a bit to give it a nice smooth effect, or it will go to fast.

    Code:
    Private Declare Sub Sleep Lib "kernel32" _
    (ByVal dwMilliseconds As Long)
    
    Private Sub Command1_Click()
    'Adjust to fit your needs
        Do Until Image1.Left = 6120
            Image1.Left = Image1.Left + 5
            Sleep 1
        Loop
    End Sub
    ^Just an example, as it says, adjust to fit your needs.
    It kind of makes an object move across the form and gives it this cool looking rolling effect. Try it, you might like it .

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