I found several threads addressing this topic, but still need some help getting my Fortran .dll file to work. I am using Windows 7, Excel 2010 and Visual Fortran Composer XE 2013 SP1. I dummed down the code from a 2002 post on this forum (titled Visual Fortran dll call from Excel/VBA)
My FORTRAN code is:
FUNCTION COMPUTEMULT ( ARG1, ARG2 )
!DEC$ ATTRIBUTES DLLEXPORT,ALIAS:'ComputeMult' :: COMPUTEMULT
REAL*4 ARG1, ARG2, COMPUTEMULT
COMPUTEMULT = ARG1 * ARG2
END FUNCTION COMPUTEMULT
My VB code is:
Public Declare Function ComputeMult Lib "c:\excel_test.dll" (A1 As Single, A2 As Single) As Single
X = 4
Y = 5
MsgBox "X= " & X
MsgBox "Y= " & Y
Z = ComputeMult(X, Y)
MsgBox "X*Y= " & Z
When i run the VB proceedure I get teh error "Bad .dll calling convention"
I also ran Dependency Walker on the excel_test.dll and recieved errors:
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
There is a link to KERNEL32.dll, despite setting the FORTRAN>library>runtime option to multithread.
Any help is appricated.