Results 1 to 4 of 4

Thread: getting the time between the time it takes to click one button ************(resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    243

    getting the time between the time it takes to click one button ************(resolved)

    how do you go about getting the time (in milliseconds) between the time it takes to click one button and then the next?

    I have already tried to use a timer and do this code

    sub timer_timer()
    a = a + 1 'a being the integer
    end sub

    When i return what a = it gives me a number like 400 even though it took me 5 seconds to click the button

    your help would be much appreasiated Thanks
    Last edited by king_scott_2; Dec 12th, 2002 at 08:51 PM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetTickCount Lib "kernel32" () As Long
    4.  
    5. Private lTime As Long
    6.  
    7. Private Sub Command1_Click()
    8.     lTime = GetTickCount
    9. End Sub
    10.  
    11. Private Sub Command2_Click()
    12.     MsgBox (GetTickCount - lTime) & " milliseconds"
    13. End Sub

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Use GetTickCount. Here's an example, make a new project, insert two command buttons and add the following code:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim Button1 As Long, Button2 As Long
    4.  
    5. Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    6.  
    7. Private Sub Command1_Click()
    8.     Button1 = GetTickCount
    9. End Sub
    10.  
    11. Private Sub Command2_Click()
    12.     Button2 = GetTickCount
    13.     Caption = "Took " & Button2 - Button1 " milliseconds"
    14. End Sub

    Hope this does the trick


    Edit Damn I'm slow

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    243
    thanks all

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