Hello, Everyone.
I am a newbie to VBA calling Fortran DLL.
I need some help getting my Fortran DLL file to work with my Excel VBA.
I am using Windows 7 (X64), Excel 2013 (X64), Microsoft Visual Studio 2015 and Visual Fortran Composer XE 2013 SP1.
【My FORTRAN code】
Function IntelRho(pi,ti)
!DEC$ ATTRIBUTES STDCALL,DLLEXPORT::IntelRho
!DEC$ ATTRIBUTES ALIAS:'IntelRho'::IntelRho
implicit real(8) (A-H,O-Z)
real(8) pi,ti,p,t,Intelrho
p=pi*1000
t=ti + 273.15
IntelRho=p/(8.31*t)
return
End Function Intelrho
【My VBA code】
Public Declare PtrSafe Function Intelrho Lib "D:\Doc\VS2015\Dll2IntelRho\x64\Debug\Dll2IntelRho.dll" (pp As Double, tt As Double) As Double
----------------------------------------------------------------------------------------------------------When I call the function in an Excel cell, such as: I put 3 in Cells(1,1), put 10 in Cells(1,2), then I call the function IntelRho in Cells(1,3) as "=IntelRho(A1,B1)", I got a wrong answer(Cells(1,3)=0). Could anyone tell what the problem is?
Any help is appricated.
Guo