CharlesDayan
Technical User
I'm trying to send two arrays (a double and a long) from VB to a FORTRAN DLL. I don't understand why I can get (without problems) all variables but my array of longs? The DLL returns the same array; it accepts the call but doesn't perform any calculation with the array!!???
Here the short code:
Subroutine VB_FOR(x,n,m,r,xx,nn,mm,rr)
implicit none
!
!MS$ATTRIBUTES DLLEXPORT :: VB_FOR
!MS$ATTRIBUTES ALIAS : 'VB_FOR' :: VB_FOR
!
Real(8) , intent(inout) :: x
Integer(2) , intent(in) :: n
Integer(2) , intent(in) :: m
Real(8) , intent(inout) :: r
Integer(4) , intent(inout) :: xx
Integer(2) , intent(in) :: nn
Integer(2) , intent(in) :: mm
Integer(4) , intent(inout) :: rr
dimension x(n,m) ! dimension of the array of doubles
dimension xx(nn,mm) ! ... array of longs
integer :: i
integer :: j
do i=1,n
do j=1,m
x(i,j)=x(i,j)*n/10 ! WORKS FINE
end do
end do
r=2.13*r*r ! WORKS FINE
do i=1,nn
do j=1,mm
xx(i,j)=xx(i,j)*xx(i,j) ! DO NOT WORK (?)
end do
end do
rr=rr*rr ! WORKS FINE
end subroutine
The Visual Basic 6 side:
Private Declare Sub VB_FOR Lib "VB_FOR.dll" (ByRef Array_Dbl As Double, ByRef Linha_Dbl As Integer, ByRef Coluna_Dbl As Integer, ByRef Duplo_Dbl As Double, ByRef Array_Lng As Long, ByRef Linha_Lng As Integer, ByRef Coluna_Lng As Integer, ByRef Longo_Lng As Long)
Sub CallDLL_Click()
.
.
.
Call VB_FOR(MyDblArr(1, 1), n, m, My_Double, MyLngArr(1, 1), nn, mn, My_Long)
.
.
.
End Sub
ANY SUGGESTION ?
Here the short code:
Subroutine VB_FOR(x,n,m,r,xx,nn,mm,rr)
implicit none
!
!MS$ATTRIBUTES DLLEXPORT :: VB_FOR
!MS$ATTRIBUTES ALIAS : 'VB_FOR' :: VB_FOR
!
Real(8) , intent(inout) :: x
Integer(2) , intent(in) :: n
Integer(2) , intent(in) :: m
Real(8) , intent(inout) :: r
Integer(4) , intent(inout) :: xx
Integer(2) , intent(in) :: nn
Integer(2) , intent(in) :: mm
Integer(4) , intent(inout) :: rr
dimension x(n,m) ! dimension of the array of doubles
dimension xx(nn,mm) ! ... array of longs
integer :: i
integer :: j
do i=1,n
do j=1,m
x(i,j)=x(i,j)*n/10 ! WORKS FINE
end do
end do
r=2.13*r*r ! WORKS FINE
do i=1,nn
do j=1,mm
xx(i,j)=xx(i,j)*xx(i,j) ! DO NOT WORK (?)
end do
end do
rr=rr*rr ! WORKS FINE
end subroutine
The Visual Basic 6 side:
Private Declare Sub VB_FOR Lib "VB_FOR.dll" (ByRef Array_Dbl As Double, ByRef Linha_Dbl As Integer, ByRef Coluna_Dbl As Integer, ByRef Duplo_Dbl As Double, ByRef Array_Lng As Long, ByRef Linha_Lng As Integer, ByRef Coluna_Lng As Integer, ByRef Longo_Lng As Long)
Sub CallDLL_Click()
.
.
.
Call VB_FOR(MyDblArr(1, 1), n, m, My_Double, MyLngArr(1, 1), nn, mn, My_Long)
.
.
.
End Sub
ANY SUGGESTION ?