- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to pass a one-dimensional array from a Fortran dll to Excel 2010.
I havesuccessfully run the sample program and I have successfully modified the sample program to return an integer instead of a string.
When I attempt to pass an array, the dll compiles and the VBA code runs. However, I get zeroes in cells A2, A3, and A4 rather than the correct numbers based on the input.
I am using Windows 7, Intel Fortran 11.075, and Excel 2010.
Thanks for any help.
Fortran code:
VBA code:
Declare Sub FortranCall Lib "Fcall.dll" (r1 As Long, num As Long)
I havesuccessfully run the sample program and I have successfully modified the sample program to return an integer instead of a string.
When I attempt to pass an array, the dll compiles and the VBA code runs. However, I get zeroes in cells A2, A3, and A4 rather than the correct numbers based on the input.
I am using Windows 7, Intel Fortran 11.075, and Excel 2010.
Thanks for any help.
Fortran code:
subroutine FortranCall (r1, num)
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"FortranCall" :: FortranCall
integer, intent(in) :: r1
integer, intent(out) :: num(5)
num = 9
num(1) = r1*100
num(2) = r1*1000
return
end subroutine FortranCall
VBA code:
Private Sub CommandButton1_Click()
Dim r1 As Long
Dim num(5) As Long
r1 = Range("A1")
Call FortranCall(r1, num(5))
Range("A2") = num(2)
Range("A3") = num(3)
Range("A4") = num(4)
End Sub
Module1:Declare Sub FortranCall Lib "Fcall.dll" (r1 As Long, num As Long)
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will answer my own question.
Call FortranCall(r1, num(5)) should be Call FortranCall(r1, num(1))
Now it works.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page