fortran生成DLL被VB调用问题
请问我用VB调用fortran生成的dll文件时简单的fortran程序(仅有两个子程序)时可以用VB调用成功,可是当参数增加后老是计算结果错误,而且不知道为什么VB不能...
请问我用VB调用fortran生成的dll文件时 简单的fortran程序(仅有两个子程序)时可以用VB调用成功,可是当参数增加后老是计算结果错误,而且不知道为什么VB不能够显示出dll程序中某参数的值,举个例子如下:
1、为何不能显示程序中某参数的值?
fortran源dll程序:
subroutine hello(a,c,e,g)
!MS$ ATTRIBUTES DLLEXPORT :: HELLO
!MS$ ATTRIBUTES ALIAS : "HELLO" :: HELLO
!MS$ ATTRIBUTES STDCALL :: HELLO
!MS$ ATTRIBUTES REFERENCE :: a,c,e,g
implicit none
real a
real b
real c
real d
real e
real g
call abc(a,b)
call dier(b,c,d)
call ccc(d,e,g)
return
end
subroutine ccc(d,e,g)
implicit none
real d
real e
real g
g=d+e
return
end
subroutine dier(b,c,d)
implicit none
real b
real c
real d
d=b+c
return
end
subroutine abc(a,b)
implicit none
real a
real b
b=a*10
return
end
VB程序代码:
Private Declare Sub HELLO Lib "11120.dll" (ByRef a As Single, ByRef c As Single, ByRef e As Single, ByRef g As Single)
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim e As Single
Dim g As Single
a =1
c = 2
e = 3
Call HELLO(a, c, e, g)
Text1.Text = Str(b)
Text2.Text = Str(d)
Text3.Text = Str(g)
End Sub
VB程序运行后 可以正确显示g的值 而b、d的值显示为0 不知道这是为什么,请你帮忙看看,我VB和fortran都是自己看的书 呵呵 好多不是很懂,让见笑了。 展开
1、为何不能显示程序中某参数的值?
fortran源dll程序:
subroutine hello(a,c,e,g)
!MS$ ATTRIBUTES DLLEXPORT :: HELLO
!MS$ ATTRIBUTES ALIAS : "HELLO" :: HELLO
!MS$ ATTRIBUTES STDCALL :: HELLO
!MS$ ATTRIBUTES REFERENCE :: a,c,e,g
implicit none
real a
real b
real c
real d
real e
real g
call abc(a,b)
call dier(b,c,d)
call ccc(d,e,g)
return
end
subroutine ccc(d,e,g)
implicit none
real d
real e
real g
g=d+e
return
end
subroutine dier(b,c,d)
implicit none
real b
real c
real d
d=b+c
return
end
subroutine abc(a,b)
implicit none
real a
real b
b=a*10
return
end
VB程序代码:
Private Declare Sub HELLO Lib "11120.dll" (ByRef a As Single, ByRef c As Single, ByRef e As Single, ByRef g As Single)
Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim d As Single
Dim e As Single
Dim g As Single
a =1
c = 2
e = 3
Call HELLO(a, c, e, g)
Text1.Text = Str(b)
Text2.Text = Str(d)
Text3.Text = Str(g)
End Sub
VB程序运行后 可以正确显示g的值 而b、d的值显示为0 不知道这是为什么,请你帮忙看看,我VB和fortran都是自己看的书 呵呵 好多不是很懂,让见笑了。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询