Results 1 to 4 of 4

Thread: Timer Object to control Animation speed

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    18

    Timer Object to control Animation speed

    Great ones,

    How is it possible to use the "Timer" object (looks like a stopwatch) to control the movement (velocity) of picture boxes across a form?

    I don't want to use the often used code below because it burns up all CPU capacity while in the loop. Using such code the CPU is always at 100% when the picture boxes are animating across the form.

    Sub Pause (Time as Single)
    Dim Start as Single
    Start = Timer
    Do While Timer < Start + Time
    Loop
    End Sub

    Does use of the "Timer" object cause CPU usage to go to 100%?

    Thank you

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Dont worry about CPU usage unless you're using really complicated loops. I would use Do...Loop with a bit of GetTickCount() thrown in.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Add a DoEvents in there... It lets Windows execute while you are in the loop.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    A pinch of Do, a smidgen of Loop, a portion of GetTickCount() and throw in a DoEvents for good measure
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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