
Passing arrays from FORTRAN dll from VB
I got it to work! I had seen some postings related to doing the same
thing with DVF and VB5.0 that said that you should just pass the first
element in an array as a scalar and apparently the rest of the array
will follow. It sounded like wishful thinking, but after some
experimentation I got it to work. I used Watcom FORTRAN11b, VB4-32
Professional, Win95 OSR2. Here's my source code:
Beginning of VB Code
******************************************************
[General] [declarations]
Private Declare Sub SubF77 Lib
"C:\WATCOM\samples\fortran\win\dll\FromWeb\Modified\Just1st\dllsampf.dll"
(ByRef a As Single)
Option Base 1 'Unnecessary? Dim a(1 To 3) As Single
Private Sub cmdF77Function_Click()
Dim a(1 To 3) As Single
'Either way this will work
' Call SubF77(a(1))
SubF77 a(1)
MsgBox "a(1) = " & a(1)
MsgBox "a(2) = " & a(2)
MsgBox "a(3) = " & a(3)
Refresh
DoEvents
End Sub
End of VB Code
*************************************************************
Beginning of FORTRAN Code
**********************************************************
*$pragma aux (__stdcall) SUBF77 "SubF77" export parm(reference)
SUBROUTINE SUBF77( D )
!Changed REAL to REAL*4 although I'm pretty sure that they are the same.
REAL*4 D(3) !Added an array
CALL SETD(D)
RETURN
END
SUBROUTINE SETD(D)
REAL*4 D(3)
D(1) = 1.
D(2) = 2.
D(3) = 3.
RETURN
END
End of of FORTRAN Code
*************************************************************
Beginning of Batch file used to compile the FORTAN
*********************************
wfc386 /d2 /bd dllsampf.for
wlink d all sys nt_dll initi termi n dllsampf f dllsampf l nt.lib
End of Batch file used to compile the FORTAN
***************************************
--
To respond via e-mail, please remove what's between Eric and Goforth in
my address in order to get my real e-mail address.
--
To respond via e-mail, please remove what's between Eric and Goforth in
my address in order to get my real e-mail address.