can't use Currency in a function declration!

  • Thread starter Thread starter Adrian
  • Start date Start date
A

Adrian

Hi

I want to use the following declarations but vb dotnet keeps complaining
that currency can't be used because it private ?

I have tried it in a module and in the declaration pare same error!



Private Declare Function QueryPerformanceFrequency Lib "kernel32" (ByVal
lpFrequency As Currency) As Long

Private Declare Function QueryPerformanceCounter Lib "kernel32" (ByVal
lpPerformanceCount As Currency) As Long
 
Adrian said:
Hi

I want to use the following declarations but vb dotnet keeps
complaining that currency can't be used because it private ?

I have tried it in a module and in the declaration pare same error!



Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(ByVal lpFrequency As Currency) As Long

Private Declare Function QueryPerformanceCounter Lib "kernel32"
(ByVal lpPerformanceCount As Currency) As Long


These are declarations for the wrong language (VB6). In VB.Net:


Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(ByRef lpFrequency As Long) As Boolean

Private Declare Function QueryPerformanceCounter Lib "kernel32"
(byref lpPerformanceCount As long) As boolean


Armin
 
Thanks for the quick reply and help

Armin Zingler said:
These are declarations for the wrong language (VB6). In VB.Net:


Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(ByRef lpFrequency As Long) As Boolean

Private Declare Function QueryPerformanceCounter Lib "kernel32"
(byref lpPerformanceCount As long) As boolean


Armin
 
this what I'm trying to do, using the code bellow I insert a call to a web
service at the "some code line" and I want to know in milisecs how long it
takes to return a response.

Private Declare Function QueryPerformanceFrequency Lib "kernel32"
(lpFrequency As Currency) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32"
(lpPerformanceCount As Currency) As Long



Dim curFreq as Currency
Dim curStart as Currency
Dim curEnd as Currency
Dim dblResult as Double

QueryPerformanceFrequency curFreq 'Get the timer frequency
QueryPerformanceCounter curStart 'Get the start time

'Some code to test

QueryPerformanceCounter curEnd 'Get the end time
dblResult = (curEnd - curStart) / curFreq 'Calculate the duration (in
seconds)

taken from http://gpwiki.org/index.php/VB:QueryPerformanceCounter
 
OK thanks again, I will try it when I get home and let you know how it goes!

And yes I'm trying to use VB dotnet

Thanks
 
Armin ,,,,,, Long ????

No not long,,, you should use the decimal datatype for currency values

regards

Michel Posseth [MCP]
 
m.posseth said:
Armin ,,,,,, Long ????

No not long,,, you should use the decimal datatype for currency
values

They are not currency values.

Currency has been used in VB6 only because there was no other 8 bytes
integer (or better: scaled integer) data type. Now we have Long.


Armin
 
Armin ,,,
'
I sure remember that when i moved from VB 6 to VB.Net that in the
conversion guides was stated that the decimal datatype should be used to
hold currency values

"Nor is the Currency data type. Instead, use the new Decimal data type,
which can handle more digits on both sides of the decimal point, for all
money variables and calculations. Decimal is also directly supported by the
common language runtime."


after a small search

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vacondatatypechanges.asp


after some googling i found that some people recomend a 64 bit integer to
hold currency values

regards

Michel Posseth
 
Armin ,,,
'
I sure remember that when i moved from VB 6 to VB.Net that in the
conversion guides was stated that the decimal datatype should be used to
hold currency values

That's true, except in this case - since they aren't storing currency
values. The need a 64-bit integer. In VB6, you had to use a currency
value (since that's what they were interanlly). In VB.NET you use Long,
which is a 64-bit integer.
"Nor is the Currency data type. Instead, use the new Decimal data type,
which can handle more digits on both sides of the decimal point, for all
money variables and calculations. Decimal is also directly supported by the
common language runtime."


after a small search

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vacondatatypechanges.asp


after some googling i found that some people recomend a 64 bit integer to
hold currency values

The decimal data type is a 64-bit integer internally.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top