Results 1 to 6 of 6

Thread: GetTickCount

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80

    GetTickCount

    GetTickCount - How do you use it and how do you define it so that you CAN use it?
    Do you know if you will answer no to this question?
    If we've never seen something happen, we can't know if its impossible.
    If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
    If someone orders you to disobey all of their orders, do you obey or disobey?

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    GetTickCount() returns a Long value containing the number of milliseconds that Windows has been running. I believe the declaration is:
    Code:
    Public Declare Function GetTickCount Lib "kernel32" () As Long
    From memory, but I think its right...

    It is usually used to determine how much time has passed between two points in code:
    Code:
    Dim s As Long
    Dim e As Long
    Dim l As Long
    s = GetTickCount()
    DoSomething
    e = GetTickCount()
    
    l = e - s
    Z.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    How would I incorporate this into a loop to make things happen every 30 ticks?
    Do you know if you will answer no to this question?
    If we've never seen something happen, we can't know if its impossible.
    If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
    If someone orders you to disobey all of their orders, do you obey or disobey?

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Code:
    Dim last As Long
    
    last = GetTickCount()
    While True
      If last + 30 < GetTickCount() Then
          last = GetTickCount()
          'DoStuff
      End If
    Wend
    Z.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2001
    Location
    2 miles from everywhere
    Posts
    80
    This is the sub I have. When a command button is pressed, this runs. WBut, when I push it, my program freezes(as well as VB). Same thing happened with Zaei's code.

    Code:
    Public Sub Run()
    Dim T As Long
        Do Until DONE = True
            T = GetTickCount + 30
            If GetTickCount >= T Then
                MouseMove
                DoEvents
           End If
        Loop
    
    End Sub
    Do you know if you will answer no to this question?
    If we've never seen something happen, we can't know if its impossible.
    If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
    If someone orders you to disobey all of their orders, do you obey or disobey?

  6. #6
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Move the DoEvents out of the If Statement.

    You are setting T at every loop iteration, which means that the If statment will NEVER fire, because T is ALWAYS 30 greater then GetTickCount. ONLY Set T inside the If statment.

    Z.

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