Results 1 to 35 of 35

Thread: Vb precise to 4 milliseconds?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Vb precise to 4 milliseconds?

    hi, I'm new to the forums here and I did a quick search but I couldn't find out exactly.. anyways my question is, can I make a VB program that will have a break of precisely 4 milliseconds or will it be variant? and if its possible what would I have to do to start that break? Thanks alot for any help

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    See the following thread that discuss multimedia timers.
    http://www.vbforums.com/showthread.php?t=326071

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Vb precise to 4 milliseconds?

    Keep in mind that timer controls are extremely inaccurate - so if you use a timer make it fire more than once in your 4 ms window (many, many times!) and then check a "clock" figure to see if the 4 ms threshold has been reached.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Vb precise to 4 milliseconds?

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetTickCount Lib "Kernel32" () As Long
    4.  
    5. Private Game_Active As Boolean
    6.  
    7. Private Milliseconds As Long
    8.  
    9. Private Sub Form_Activate()
    10.  
    11.     Milliseconds = GetTickCount
    12.    
    13.     Game_Active = True
    14.    
    15.     While Game_Active = True
    16.        
    17.         DoEvents
    18.        
    19.         If GetTickCount - Milliseconds >= 4 Then '4 milliseconds
    20.            
    21.             MsgBox GetTickCount - Milliseconds          
    22.  
    23.             Game_Active = False 'Breaks out of the loop
    24.            
    25.         End If
    26.        
    27.     Wend
    28.            
    29.     Unload Me
    30.  
    31. End Sub

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    GetTickCount only have an accurasy of about 10ms. If you need lower resolution you need to use multimedia timers. The built in Timer in VB can not be used for such low resolution.

  6. #6
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Vb precise to 4 milliseconds?

    GetPerformanceFrequence and GetPerformanceQuerery is the best. The timer that was used in the contest on this forum relied on it. I belice the source code is still in a thread there.


    ØØ

  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Vb precise to 4 milliseconds?

    Here you go.

    http://vbforums.com/showpost.php?p=1783665&postcount=52

    Even a sample to go with it. But I guess you have to tweak it a bit to make use of it in your app.




    ØØ

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by NoteMe
    GetPerformanceFrequence and GetPerformanceQuerery is the best. The timer that was used in the contest on this forum relied on it. I belice the source code is still in a thread there.
    The forum link I posted in the first reply discuss these.

  9. #9
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by Joacim Andersson
    GetTickCount only have an accurasy of about 10ms. If you need lower resolution you need to use multimedia timers. The built in Timer in VB can not be used for such low resolution.
    On the conterary, it has the accuracy of 1 ms. I use it all the time and it works in real time. Don't believe me? Try my code and fiddle with the milliseconds to break out of.

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by Jacob Roman
    On the conterary, it has the accuracy of 1 ms. I use it all the time and it works in real time. Don't believe me? Try my code and fiddle with the milliseconds to break out of.
    Not true! At least not according to Microsoft:
    http://support.microsoft.com/kb/q172338/

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by Jacob Roman
    On the conterary, it has the accuracy of 1 ms. I use it all the time and it works in real time. Don't believe me? Try my code and fiddle with the milliseconds to break out of.

    It is OS dependent.



    MSDN:
    The following table describes the resolution of the system timer.

    System Resolution
    Windows NT 3.5 and later The system timer runs at approximately 10ms.
    Windows NT 3.1 The system timer runs at approximately 16ms.
    Windows 95 and later The system timer runs at approximately 55ms.

  12. #12
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Vb precise to 4 milliseconds?

    That's funny. Works fine on my comp that has Windows ME and my dads comp that has Windows XP Pro SP2

  13. #13
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Vb precise to 4 milliseconds?

    Hey everyone - this timer debate has been done before...

    BTW - Izno - welcome to the forum.

    Maybe we should ask what you are trying to do with this 4 ms window?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  14. #14
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by Jacob Roman
    That's funny. Works fine on my comp that has Windows ME and my dads comp that has Windows XP Pro SP2
    So between two calls to GetTickCount you might get the result down to 1ms, but that in real time it might have past 10.
    You can NOT get lower accuracy with the system timer, you need to use a hardware multimedia timer to get a better resolution. Why would they otherwise bother to build computers that has them if you could get the same accuracy using a software timer?

  15. #15
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by Joacim Andersson
    The forum link I posted in the first reply discuss these.

    I read thgough it now. You wrote Multimeda Timer before the link, so I though it was discussing the multimeda timer API, not the other Timer APIs. I can't see that they are discussing the multimedia timer API at all on that page actualy.



    ØØ

  16. #16
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Re: Vb precise to 4 milliseconds?

    Finaly I found it. Kedas thread where all the timers are tested against each other.

    http://vbforums.com/showthread.php?t...ltimedia+timer




    ØØ

  17. #17

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    thanks for the replies so far I'm still waiting for the answers to a few of my questions before I will be putting it in, but I want a to build a program that flashes a dot and then displays a word for 4 milliseconds, and then that will be built into an array of words, it's for a psychology experiment

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Vb precise to 4 milliseconds?

    I don't think the eye can pick up anything near that fast. The eye gets fooled at 60 fps, i thought, as that is what motion pictures frame out at?

  19. #19
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    I don't know if the eye can handle it, but your monitor probably can't.
    Let's save you have a refresh rate of 85Hz, that's a refresh every 12ms. so, the best you could do if you snyc'd it right, is put something on the screen every 12ms.

  20. #20
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by dglienna
    I don't think the eye can pick up anything near that fast. The eye gets fooled at 60 fps, i thought, as that is what motion pictures frame out at?
    The eye get's fooled at about 15 fps. Motion pictures at the cinema use 24 fps and the VHS system use 25 fps.

  21. #21
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Vb precise to 4 milliseconds?

    Last edited by dglienna; Mar 1st, 2005 at 03:55 AM.

  22. #22
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    This is probably an experiment on subliminal messages which is a crock anyway.

  23. #23

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    hey guys, I've tried coding it but I'm a VB noob and I could use some help with my code. What I want is for some words to appear for 4 milliseconds (although as expressed here 17 seems to be the quickest Vb can handle but that will work) and some words to appear for 5 full seconds. I also want a dot to appear before all of the words for 4 seconds and a bunch of X's to appear after the word has been presented for its amount of time. Any help would be greatly appreciated this is what I have thus far but right now all I get is the line of X's, with no dot or words being presented whatsoever.

    Private Sub cmdSecond_Click()
    'clicking the button that does the real testing
    'setting array value appropriately
    If IntSecondArray > 19 Then
    IntSecondArray = 0
    End If

    'assigning array values to the second array for the words in the timed list
    If StrSecondWordArray(0) = "" Then
    StrSecondWordArray(0) = "Climb"
    StrSecondWordArray(1) = "Ballet"
    StrSecondWordArray(2) = "Sight"
    StrSecondWordArray(3) = "Cat"
    StrSecondWordArray(4) = "Might"
    StrSecondWordArray(5) = "With"
    StrSecondWordArray(6) = "Valid"
    StrSecondWordArray(7) = "Doll"
    StrSecondWordArray(8) = "Consent"
    StrSecondWordArray(9) = "Time"
    StrSecondWordArray(10) = "Sew"
    StrSecondWordArray(11) = "Smite"
    StrSecondWordArray(12) = "Dog"
    StrSecondWordArray(13) = "Scripts"
    StrSecondWordArray(14) = "Yacht"
    StrSecondWordArray(15) = "Conscience"
    StrSecondWordArray(16) = "Chic"
    StrSecondWordArray(17) = "Chalet"
    StrSecondWordArray(18) = "Limb"
    StrSecondWordArray(19) = "Hat"
    End If
    'setting variables to zero prior to measurement of time and loop

    curFinishTime = 0
    dblTime = 0

    QueryPerformanceCounter curStartTime 'taking starting time then starting the timer
    Do Until dblTime >= 4
    'coding for the fixation dot
    lblword.Caption = "*"

    QueryPerformanceCounter curFinishTime
    dblTime = curFinishTime - curStartTime
    Loop


    'clearing the timer variables before timing again
    curFinishTime = 0
    dblTime = 0


    QueryPerformanceCounter curStartTime 'taking starting time then starting the timer
    Select Case IntSecondArray 'coding for the 4 millisecond displays
    Case 1, 3, 5, 6, 8, 10, 11, 12, 14, 15
    Do Until dblTime >= 0.004
    lblword.Caption = StrSecondWordArray(IntSecondArray)
    QueryPerformanceCounter curFinishTime
    dblTime = curFinishTime - curStartTime
    Loop

    Case Else 'coding for the 5 second displays
    Do Until dblTime >= 5
    lblword.Caption = StrSecondWordArray(IntSecondArray)
    QueryPerformanceCounter curFinishTime
    dblTime = curFinishTime - curStartTime
    Loop

    End Select

    lblword.Caption = "XXXXXXXXXXXXX"
    IntSecondArray = IntSecondArray + 1

    End Sub

  24. #24

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    could anyone please help me improve on this?

  25. #25
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    could anyone please help me improve on this?
    We could, but I'm not sure you'd listen.

    Let me try it again: You cannot display something at a rate faster than your monitor scan rate. So for example, if your refresh rate is 75Hz then the fastest you could do would be once every 14ms. That is assuming you could sync your program to the monitor. Failing that you would have to leave the word there for a little longer just to make sure. With this in mind you might want to make a few changes to your loops
    VB Code:
    1. Select Case IntSecondArray
    2. Case 1, 3, 5, 6, 8, 10, 11, 12, 14, 15
    3.     lblword.Caption = StrSecondWordArray(IntSecondArray)
    4.     DoEvents
    5.     QueryPerformanceCounter curStartTime
    6.     Do Until dblTime >= MyRefreshRate
    7.       QueryPerformanceCounter curFinishTime
    8.       dblTime = curFinishTime - curStartTime
    9.     Loop

  26. #26

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    thanks for the help so far, I changed the timer so that it should be within reasonable limits for the monitor (20 ms) . I changed most of the code to work with the subs provided by Noteme here's what I have now. all I'm trying to do is display the asterisk for 4 seconds, then either display a word for 20 milliseconds, or for 5 seconds depending on which array position it is in then the row of X's. all I am getting at the moment is a pause followed by a white box around where the label box is located followed by the X's, it shouldn't be a problem with refresh rate though since the 5 second word display isn't working either. q.rettime returns the value of time that has elapsed from q.starttime to q.stoptime

    VB Code:
    1. q.Init
    2.  
    3. 'coding the fixation point
    4. lblword.Caption = "*"
    5. q.StartTime
    6. Do Until q.RetTime >= 4
    7.     q.StopTime
    8. Loop
    9.  
    10.  
    11. Select Case IntSecondArray 'coding for the 20 millisecond displays
    12.     Case 1, 3, 5, 6, 8, 10, 11, 12, 14, 15
    13.         lblword.Caption = StrSecondWordArray(IntSecondArray)
    14.         q.StartTime
    15.         Do Until q.RetTime >= 0.02
    16.         q.StopTime
    17.     Loop
    18.  
    19.  
    20.     Case Else 'coding for the 5 second displays
    21.         lblword.Caption = StrSecondWordArray(IntSecondArray)
    22.         q.StartTime
    23.         Do Until q.RetTime >= 5
    24.         q.StopTime
    25.     Loop
    26.  
    27.    
    28. End Select
    29.  
    30.  
    31. IntSecondArray = IntSecondArray + 1
    32. lblword.Caption = "XXXXXXXXXXXXXXX"
    33. End Sub
    Last edited by Izno; Mar 22nd, 2005 at 05:39 PM.

  27. #27
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    post your q class,
    what is q.starttime, stoptime etc...
    If it's not too much trouble, post the whole things so I can run it here.
    if you want to post a subset of your code, include everything needed to make it work.

  28. #28

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    no problem thanks again
    there is a label button called lblword and the command button cmdsecond is the one with the issues, the first is just a list with no timers.
    VB Code:
    1. Option Explicit
    2. 'word array variables
    3. Dim IntFirstArray As Integer 'the varibles used to keep track of position in the two buttons
    4. Dim IntSecondArray As Integer
    5. Dim StrWordStore As String
    6. Dim StrStartWordArray(0 To 9) As String 'array for first list, easy scroll through
    7. Dim StrSecondWordArray(0 To 20) As String 'array for second button with timing involved
    8.  
    9. 'timer variables
    10. Private tFreq As Currency
    11. Private tStart As Currency
    12. Private tStop As Currency
    13. Private gTC As Boolean
    14.  
    15.  
    16. Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
    17. Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
    18. Private Declare Function GetTickCount Lib "kernel32" () As Long
    19. 'these above are functions that are used in calculating the time using an API function for maximum accuracy
    20.  
    21. Public Property Get RetTime() As Double
    22.     RetTime = in_RetTime 'Returns Seconds
    23. End Property
    24.  
    25. Public Sub Init()
    26.     QueryPerformanceFrequency tFreq
    27.     If tFreq = 1000 Then
    28.         gTC = True
    29.     Else
    30.         gTC = False
    31.     End If
    32. End Sub
    33.  
    34. Public Sub StopTime()
    35.     If gTC Then
    36.         tStop = CCur(GetTickCount)
    37.     Else
    38.         QueryPerformanceCounter tStop
    39.     End If
    40.     in_RetTime = (tStop - tStart) / tFreq
    41. End Sub
    42.  
    43. Public Sub StartTime()
    44.     If gTC Then
    45.         tStart = CCur(GetTickCount)
    46.     Else
    47.         QueryPerformanceCounter tStart
    48.     End If
    49. End Sub
    50.  
    51.  
    52. Private Sub cmdFirst_Click()
    53. 'this is the coding for the button that merely displays the words one after another in a loop
    54.  
    55.  
    56.  
    57.  
    58. If IntFirstArray > 9 Then
    59. MsgBox "End of List, restarting"
    60. IntFirstArray = 0
    61. End If
    62.  
    63. StrStartWordArray(0) = "Slight"
    64. StrStartWordArray(1) = "Benign"
    65. StrStartWordArray(2) = "Yacht"
    66. StrStartWordArray(3) = "Climb"
    67. StrStartWordArray(4) = "Ballet"
    68. StrStartWordArray(5) = "Bind"
    69. StrStartWordArray(6) = "Although"
    70. StrStartWordArray(7) = "Psyche"
    71. StrStartWordArray(8) = "Might"
    72. StrStartWordArray(9) = "Fetus"
    73.  
    74.  
    75. lblword.Caption = StrStartWordArray(IntFirstArray)
    76.  
    77. IntFirstArray = IntFirstArray + 1
    78.  
    79.  
    80. End Sub
    81.  
    82. Private Sub Form1_Load()
    83. IntFirstArray = 0
    84. IntSecondArray = 0
    85. CmdNext.SetFocus
    86.  
    87.  
    88.  
    89. lblword.Caption = StrStartWordArray(IntArray)
    90.  
    91. End Sub
    92.  
    93.  
    94. Private Sub cmdSecond_Click()
    95. Dim q As New sTime 'this is the variable used to call the time subs
    96. 'clicking the button that does the real testing
    97. 'setting array value appropriately
    98. If IntSecondArray > 19 Then
    99. IntSecondArray = 0
    100. End If
    101.  
    102.  
    103.  
    104. 'assigning array values to the second array for the words in the timed list
    105. If StrSecondWordArray(0) = "" Then
    106.     StrSecondWordArray(0) = "Climb"
    107.     StrSecondWordArray(1) = "Ballet"
    108.     StrSecondWordArray(2) = "Sight"
    109.     StrSecondWordArray(3) = "Cat"
    110.     StrSecondWordArray(4) = "Might"
    111.     StrSecondWordArray(5) = "With"
    112.     StrSecondWordArray(6) = "Valid"
    113.     StrSecondWordArray(7) = "Doll"
    114.     StrSecondWordArray(8) = "Consent"
    115.     StrSecondWordArray(9) = "Time"
    116.     StrSecondWordArray(10) = "Sew"
    117.     StrSecondWordArray(11) = "Smite"
    118.     StrSecondWordArray(12) = "Dog"
    119.     StrSecondWordArray(13) = "Scripts"
    120.     StrSecondWordArray(14) = "Yacht"
    121.     StrSecondWordArray(15) = "Conscience"
    122.     StrSecondWordArray(16) = "Chic"
    123.     StrSecondWordArray(17) = "Chalet"
    124.     StrSecondWordArray(18) = "Limb"
    125.     StrSecondWordArray(19) = "Hat"
    126. End If
    127. 'setting variables to zero prior to measurement of time and loop
    128.  
    129.  
    130. q.Init
    131.  'taking starting time then starting the timer
    132.  
    133. 'coding the fixation point
    134. lblword.Caption = "*"
    135. q.StartTime
    136. Do Until q.RetTime >= 4
    137.     q.StopTime
    138. Loop
    139.  
    140.  
    141. Select Case IntSecondArray 'coding for the 4 millisecond displays
    142.     Case 1, 3, 5, 6, 8, 10, 11, 12, 14, 15
    143.         lblword.Caption = StrSecondWordArray(IntSecondArray)
    144.         q.StartTime
    145.         Do Until q.RetTime >= 0.02
    146.         q.StopTime
    147.     Loop
    148.  
    149.  
    150.     Case Else 'coding for the 5 second displays
    151.         lblword.Caption = StrSecondWordArray(IntSecondArray)
    152.         q.StartTime
    153.         Do Until q.RetTime >= 5
    154.         q.StopTime
    155.     Loop
    156.  
    157.    
    158. End Select
    159.  
    160.  
    161. IntSecondArray = IntSecondArray + 1
    162. lblword.Caption = "XXXXXXXXXXXXXXX"
    163. End Sub

  29. #29
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    OK, I have it in a project, but

    Dim q As New sTime

    don't have this sTime thing
    is it a class that you can include the code for?

  30. #30

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    yeah, here it is

    VB Code:
    1. '******* sTime.cls *******
    2. 'PROPERTY:
    3. Private in_RetTime As Double
    4.  
    5. 'VARIABLES:
    6. Private tFreq As Currency
    7. Private tStart As Currency
    8. Private tStop As Currency
    9. Private gTC As Boolean
    10.  
    11. 'DECLARATIONS:
    12. Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
    13. Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
    14. Private Declare Function GetTickCount Lib "kernel32" () As Long
    15.  
    16. Public Property Get RetTime() As Double
    17.     RetTime = in_RetTime 'Returns Seconds
    18. End Property
    19.  
    20. Public Sub Init()
    21.     QueryPerformanceFrequency tFreq
    22.     If tFreq = 1000 Then
    23.         gTC = True
    24.     Else
    25.         gTC = False
    26.     End If
    27. End Sub
    28.  
    29. Public Sub StopTime()
    30.     If gTC Then
    31.         tStop = CCur(GetTickCount)
    32.     Else
    33.         QueryPerformanceCounter tStop
    34.     End If
    35.     in_RetTime = (tStop - tStart) / tFreq
    36. End Sub
    37.  
    38. Public Sub StartTime()
    39.     If gTC Then
    40.         tStart = CCur(GetTickCount)
    41.     Else
    42.         QueryPerformanceCounter tStart
    43.     End If
    44. End Sub

  31. #31
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    OK,
    Here is a change you need to make. Each time you change a label you will need to force the label to repaint by calling the Refresh method.
    VB Code:
    1. lblword.Caption = StrSecondWordArray(IntSecondArray)
    2.         lblword.Refresh
    3.         q.StartTime

  32. #32

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    8

    Re: Vb precise to 4 milliseconds?

    Awesome, thank you a ton Moeur I think I've finally got it! thanks a bunch to the rest of you guys too it was definately a group effort

  33. #33
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Vb precise to 4 milliseconds?

    Post it. I'd like to see what my laptop can do as far as fast refresh rate.

  34. #34
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Vb precise to 4 milliseconds?

    Here's a timer that supposedly has millisecond accuracy.

    http://vb.mvps.org/samples/project.asp?id=StopWatch

    VBAhack

  35. #35
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Vb precise to 4 milliseconds?

    Quote Originally Posted by VBAhack
    Here's a timer that supposedly has millisecond accuracy.
    Dude, we're beyond that. He's got much better than millisecond resolution.

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