I am having trouble passing a string from Excel VBA to be converted and processed in PB 6.0, and then passing back a derived double precision value. Only the first digit of the string appears in the worksheet; "88.5C" for example should return 88.5, but only 8 is returned. Using the debugger shows that the internal conversion in PB 6 is perfect.
This toy program shows the essentials of the problem:
In Excel VBA:
Option Explicit
Declare Function CNVSTR Lib "Tryadd.dll" _
(ByVal Coord AS STRING) AS DOUBLE
$COMPILE DLL
FUNCTION CNVSTR(s AS ASCIIZ) EXPORT AS DOUBLE
DIM Result AS DOUBLE
Result = VAL(s)
CNVSTR = Result
END FUNCTION
Changing ASCIIZ to STRING and leaving out the ByVal does not help.
I am aware of the care to be taken with strings between VBA and PB, but I am baffled why a double precison value derived from a passed string is getting truncated to one digit. Help!
John Lenihan
This toy program shows the essentials of the problem:
In Excel VBA:
Option Explicit
Declare Function CNVSTR Lib "Tryadd.dll" _
(ByVal Coord AS STRING) AS DOUBLE
$COMPILE DLL
FUNCTION CNVSTR(s AS ASCIIZ) EXPORT AS DOUBLE
DIM Result AS DOUBLE
Result = VAL(s)
CNVSTR = Result
END FUNCTION
Changing ASCIIZ to STRING and leaving out the ByVal does not help.
I am aware of the care to be taken with strings between VBA and PB, but I am baffled why a double precison value derived from a passed string is getting truncated to one digit. Help!
John Lenihan
Comment