A Currency data type in VB is not a LONG with four implied decimal places.
It is a QUAD (8 Bytes) with four implied decimal places.
Joe Murphy
------------------
Announcement
Collapse
No announcement yet.
I need help!
Collapse
X
-
Have you tried to do this:
Code:PB function Function PBreturnCurrency(Arg as any)[b]Export As Cur[/b](rency) Declared in VB like this Declare Function "PBRETURNCURRENCY" Lib "MYDLL.DLL"(Arg as Any)[b]AS DOUBLE[/b]
Sorry, I should have read Semens thread before writing the reply....
------------------
Fred
mailto:[email protected][email protected]</A>
http://www.oxenby.se
[This message has been edited by Fred Oxenby (edited December 07, 2000).]
Leave a comment:
-
-
Thanks Semen,
I have just solved the problem in a much simpler way. If anyone is
interested the currency variable is just a Long variable that
is read with 4 implied decimal places. Therefore in the PB DLL
declare the function as
Function functionname(arg as any)export as long
but in VB VBA declare the function
declare function functionname(arg as any) as currency
In the DLL you have to make sure the result returned has enough
digits. For example if the value you want to return is 100.75
you need to ensure that the long returned reads 1007500
This works fine for me, however does anybody know a reason
why I shouldn't do this.
Regards
Trevor
------------------
Leave a comment:
-
-
we already discussed this trouble http://www.powerbasic.com/support/pb...ead.php?t=1895
------------------
e-mail: [email protected]
Leave a comment:
-
-
I need help!
Well, I got that job programming in MS Access, you don't have to feel
sorry for me though! I have bought PB/DLL to speed up my programs
and it works well. But! I am having to code around several problems
that I am sure I shouldn't have to do. So what am I doing wrong.
The first project I have been given is a data takeon program from
a system that is so old that it still uses big endian numbers what
a perfect use for my newly aquired DLL compiler
I read the file as a string (Binary) convert to small endian and
to my main function as a LONG, INT, whatever.
except the whatever does not work.
an example.
Code:function ConvertLong alias "convertLong"(arg as string) as long dim lngTemp as long 'convert the string to small endian here then convert to 'a long using a union function = lngTemp end function
Code:function ConvertCurr alias "convertCurr"(arg as string) as currency dim lngTemp as long dim curTemp as cur 'convert the string to small endian here then convert to 'a long using a union curTemp = lngtemp/100 function = curTemp end function
my workaround:
from VBA call the convertLong function that works then
Code:curVariable = ccur(lngResult/100)
cannot divide by 100 and return a currency from within PB/DLL.
according to the help file both PB and VB VBA use the same format
for currency as long as I avoid cux.
This should be so simple. I feel like a real idiot.
------------------
Tags: None
-
Leave a comment: