I have one function I'd like to call in this old dll. I
believe I am calling it correctly, because of the errors I
am getting, but it is not working.
The funtion takes these arguments:
Inputs:
NOPRT - CHAR*1
L - Integer
MILGRD - Char*(*)
ISQR - Integer
Outputs:
XLAT - D. Prec.
XLON - D. Prec
IERROR - INTEGER
I have called the function as such:
DECLARE FUNCTION MilGridToLatLon Lib "c:\convert.dll"
Alias "#2" (ByVal NORPT as Char, ByVal L as Integer, ByVal
MILGRD as String, ByVal ISQR as Integer, ByRef XLAT as
IntPtr, ByRef XLON as IntPtr, ByRef IError as IntPtr)
Then after the function I try to marshall the pointers to
a string.
I have never marshaled before, this is all new to me, but
from what I have read, this seems like the right approach.
Can someone please help??
Thank you!
You can respond at sara@nospam-ilovecode.com
Bart Jacobs - 22 Dec 2003 16:32 GMT
Sara,
Try the following:
Declare Function MilGridToLatLon
Lib "c:\convert.dll"
Alias "#2" (
ByVal NORPT as Char,
ByVal L as Integer,
ByVal MILGRD as String,
ByVal ISQR as Integer,
ByRef XLAT as Double,
ByRef XLON as Double,
ByRef IError as Integer)
Greetings
Bart Jacobs
Thanks for replying,
I had tried that initially, but when i looked at the
contents before I cll the function as well as after, they
remain the same, nothing was changed. That is why I went
the IntPtr route. But with that route I get a runtime
error:
PInvoke: Cannot return variants.
Bart Jacobs - 22 Dec 2003 18:20 GMT
Sara,
Try "Declare Sub" instead of "Declare Function".
Also, is there any additional information about the DLL entry point in
addition to the Fortran input and output variables? For example, a C
header file or documentation directed at C programmers, or some
documentation on interop with other languages in the Fortran compiler's
reference manual?
Good luck!
Bart Jacobs
Max - 23 Dec 2003 07:40 GMT
Any function in VB has a return value. If it's type is not specified, basic
assumes variant (Any).
Your Fortran function does not return variant.
What does it return?
Try adding "As System.Void" at the end of your function declaration in VB.
One more idea:
Declare Function MilGridToLatLon
Lib "c:\convert.dll"
Alias "#2" (
ByVal NORPT as Char,
ByVal L as Integer,
ByVal MILGRD as String,
ByVal ISQR as Integer,
ByRef XLAT as Double,
ByRef XLON as Double
) As Integer
> Thanks for replying,
>
[quoted text clipped - 5 lines]
>
> PInvoke: Cannot return variants.