Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: maxsteak on January 25, 2012, 03:55:20 AM
-
Hello,
After searching on the web for implementing the QueryPerformanceCounter, the workaround is using currency type. However, I have a type mismatch issue.
Can you please advice how to make it work?
Option Explicit
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Private Sub Form_Load()
Dim cTimer As Currency
Dim cTimer2 As Currency
Dim Freq As Currency
Dim i As Long
Dim temp As Double
QueryPerformanceFrequency Freq 'get frequency
QueryPerformanceCounter cTimer 'get first time
'do your stuff here stuff
For i = 1 To 2000000
temp = Sqr(i / 20 * (50 Mod i) ^ 3.333)
Next
QueryPerformanceCounter cTimer2 'get second time
Print Round((cTimer2 - cTimer) / Freq, 5) & "s" 'subtract first from second. then divide by freq.
End Sub
-
AFAIK the currency type isn't supported by CB. It's listed yes - but supported no. FWIW the currency type as used here is a complete kludge anyway and is only used because VB (and thus CB) doesn't support unsigned types - which as you've found can be a real PITA - Thank Bill G. for that.