Hello Guest it is April 29, 2024, 12:09:50 AM

Author Topic: QueryPerformanceCounter in currency type mismatch  (Read 2541 times)

0 Members and 1 Guest are viewing this topic.

QueryPerformanceCounter in currency type mismatch
« 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?

Quote
    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

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: QueryPerformanceCounter in currency type mismatch
« Reply #1 on: January 30, 2012, 01:07:31 PM »
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.