Hello every one,
I am trying to use Fortran dll in VBA of Excel 2010, but I have a problem now.
I want to get virtual array as returned value, but failed. Here is my code,
* fortran 11
subroutine virtualArrayTest(iv_array,ii)
!DEC$ ATTRIBUTES STDCALL,REFERENCE,DLLEXPORT,ALIAS:"virtualArrayTest"::virtualArrayTest
implicit none
integer,intent(out):: ii
integer,allocatable,intent(out) :: iv_array(:)
ii = 3
allocate(iv_array(3))
iv_array = 9
return
end subroutine
* visual basic macro
Option Explicit
Option Base 1
Private Declare Sub virtualArrayTest Lib "Dll1.dll" (ByRef iv_array() As Long, ByRef ii As Long)
Sub vattt()
Dim iv_a() As Long
Dim ii As Long
Call virtualArrayTest(iv_a, ii)
Cells(7, 1) = iv_a(1)
Cells(8, 1) = iv_a(2)
Cells(9, 1) = iv_a(3)
End Sub
Excel quit when running. What is the matter?
Thanks very much for any suggestion.