从VB.Net调用Fortran dll

从VB.Net调用Fortran dll,vb.net,dll,fortran,Vb.net,Dll,Fortran,下面的代码包含来自vb.net的fortran77 dll调用,具有二维数组和结构。输入参数是flg&a_in.,它计算一些值,然后依次填充a_pn和a_vOUT中的输出数组,。fortran dll中使用了一个addressof回调函数。我无法获取输出值以继续 --带有Fortran dll调用的VB.Net代码-- Dim flg As Int32 Dim a_in(,) As Double --- Input array with values Dim a_PN(,) as Double

下面的代码包含来自vb.net的fortran77 dll调用,具有二维数组和结构。输入参数是flg&a_in.,它计算一些值,然后依次填充a_pn和a_vOUT中的输出数组,。fortran dll中使用了一个addressof回调函数。我无法获取输出值以继续

--带有Fortran dll调用的VB.Net代码--

Dim flg As Int32
Dim a_in(,) As Double --- Input array with values
Dim a_PN(,) as Double ----Output array return from Fortran77 DLL (Value calculated from a_in(,) array and returns)
Dim a_vOUT(,) as Double ----Output array return from Fortran77 DLL 
Dim a_Flgs(,) as Int32
Dim a_b() as byte
Dim a_string1 As New VB6.FixedLengthString(255)

Public Structure Case_Info
    Dim nx() As Double
    Dim ny() As Double
    Dim tc() As Double
    Dim ip(,) As Double
End Structure

 W_Ftrn(Flg, a_in(1, 1), a_PN(1, 1),a_vOUT(1, 1), a_Flgs(1, 1), .TC(1), .ip(1, 1),.nx(1), .ny(1), AddressOf CallBack0, AddressOf CallBack1, a_b(1), a_string1.Value, 255)
--vb.net中的Fortran声明-

 Public Declare Sub W_Ftrn _
       Lib "D:\Proj2\Fortran.DLL" Alias "W_Ftrn" _
      (ByRef flg As integer,ByRef a_in As Double, ByRef a_PN As Double, ByRef a_vOUT As Double, ByRef a_Flgs As Int32, _
       ByRef constray As Double, ByRef ipn As Double, _
       ByRef aGX%, ByRef aGY#, _
       ByVal cbaddr0 As long,ByVal cbaddr1 As long,ByRef bPlain As Byte, _
       ByVal s1 As String, ByRef L1 As Int32)

我的猜测是,您必须在F77调用之前和之后手动复制要写入的数组单元格。大概是这样的:

Dim a_in1 As Double 
Dim a_PN1 as Double 
Dim a_vOUT1 as Double 
Dim a_Flgs1 as Int32
Dim a_b1 as byte
Dim nx As Double
Dim ny As Double
Dim tc As Double
Dim ip1 As Double

' copy-in, manually '
a_in1 = a_in(1, 1)
a_PN1 = a_PN(1, 1)
a_vOUT1 = a_vOUT(1, 1)
a_Flgs1 = a_Flgs(1, 1)
tc = .TC(1)
ip1 = .ip(1, 1)
nx = .nx(1)
ny = .ny(1)
a_b1 = a_b(1)

W_Ftrn(Flg, a_in1, a_PN1,a_vOUT1, a_Flgs1, TC, ip1, nx, ny, AddressOf CallBack0, AddressOf CallBack1, a_b1, a_string1.Value, 255)

' copy-out, manually '
a_in(1, 1) = a_in1
a_PN(1, 1) = a_PN1
a_vOUT(1, 1) = a_vOUT1 
a_Flgs(1, 1) = a_Flgs1
.TC(1) = tc 
.ip(1, 1) = ip1
.nx(1) = nx
.ny(1) = ny
a_b(1) = a_b1 

你会犯什么错误?你试图解决什么问题?W_Ftrn是如何定义Fortran源代码的?即使在VB6中,这也不应该起作用,因为数组单元格引用是逐引用传递的。事实上,它们无法被写回。