Results 1 to 4 of 4

Thread: Loop Until Timer > t + 0.5

  1. #1

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526

    Loop Until Timer > t + 0.5

    I know there's going to be some guffaws from the gallery, but hey, I'm a newbie where graphics are concerned . . .

    Okay, I searched to try to get a real basic example of bitblt but I couldn't find a basic enough example that I could paste in and see how it works and I didn't really know how to make a bunch of frames tacked on side by side in a single pic.

    That being said, I tried this method:

    Code:
    Private Sub Command1_Click()
      For a = 0 To 4
      t = Timer
      Do
        DoEvents
        If a > 0 Then pic(a - 1).Visible = False
      Loop Until Timer > t + 0.5
      Next a
    End Sub
    Why is it so damn slow? I thought Loop Until Timer > t + 0.5 would give me a pretty accurate 1/2 second frame rate.
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Try this:

    Code:
    Private Sub Command1_Click()
        Dim A As Long
        Dim Temp As Single
        
        While A < 5
            If Temp < Timer Then
                Temp = Timer + 0.5
                
                pic(A).Visible = False
                A = A + 1
            End If
            
            DoEvents
        Wend
    End Sub
    
    
    'Code improved by vBulletin Tool 2.0
    Last edited by Fox; Dec 14th, 2001 at 01:26 PM.

  3. #3

    Thread Starter
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    DUDE! That's awesome. I'll have to read up on those singles and figure out why it works on a single and not on a long.
    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Actually, the reason is it's always checking agains an old number.

    In your code, it looks for this:
    Code:
    t = 1000: timer = 1500: execute code.
    t = 1000: timer = 2000: execute code.
    If you had updated t each time it matched t + 0.5, your code would have worked.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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