Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Call Fortran dll from Excel VBA

yusining
Beginner
496 Views

Hi,

I try to call fortran dllsubroutine in Excel VBA. But the VBA code stop running whenit calls the sub. There is no error message. The VBA function return #Value!

Here is my fortran code

subroutine simple(x,y)

!DEC$ ATTRIBUTES STDCALL,REFERENCE,ALIAS:'simple' :: simple

real*8 :: x,y

y=x+5.d0

end subroutine simple

Here is my VBA code

Private Declare Sub simple Lib "C:schoolsimple.dll" (x As Double, y As Double)

Function test1(a As Double) As Double

Dim b As Double

call simple(a,b)

test1=b

End Function

Could you tell me what's wrongwith my dll. Thank you very much!

Sarah

0 Kudos
2 Replies
yusining
Beginner
496 Views

Hi,

I just solved the problem by myself.Just deletestdcall,reference in fortran code, it works smoothly now. I guess that statement just work for visual basic, not for VBA.

Thank you anyway.

Sarah

0 Kudos
Steven_L_Intel1
Employee
496 Views
That's very odd. As far as I know, STDCALL is required for that.
0 Kudos
Reply