Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
The following snippet demonstrates the use of the ...
E-mail:
Click to e-mail author
Website:
http://www.a1vbcode.com
Submitted:
5/10/2000
Version:
VB5
Compatibility:
VB5, VB6
Category:
Windows API
Views:
9596
The following snippet demonstrates the use of the GetTickCount API function. The return value is the number of milliseconds that have elapsed since the operating system was booted. This function is ideal for measuring how much time it takes to execute a function or a block of code or event a statement.
Declarations:
Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Code:
'This code will display the amount of time elapsed in seconds 'to execute a loop 100 times. 'Place this code in a command button's click event. Private Sub cmdElapsedTime_Click() Dim I As Long Dim LUBound As Long Dim Start As Long Dim LEnd As Long 'Set upper bound of loop. LUBound = 100 'Get starting tick value. Start = GetTickCount 'Execute loop. For I = 1 To LUBound Next I 'Get ending tick value. LEnd = GetTickCount 'Display elapsed time. MsgBox "Time elapsed = " & CStr((LEnd - Start) /1000) & " seconds." End Sub
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement