- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
VB Form 1: Option Explicit Private Sub Command1_Click() Dim I As Integer I = 20 MsgBox (I) SimpleFortranSub I MsgBox (I) End Sub VB Module1: Option Explicit Declare Sub SimpleFortranSub Lib "C:dev2EXAMPLESimpleFortranSub.dll" (ByRef I As Integer) Fortran DLL: subroutine SimpleFortranSub (TestInt) !DEC$ ATTRIBUTES DLLEXPORT::SimpleFortranSub !DEC$ Attributes alias : "SimpleFortranSub" :: SimpleFortranSub Integer*2 TestInt TestInt = TestInt + 1 end subroutine SimpleFortranSub
Message Edited by tmadden@linkamericacorp.com on 12-21-2004 06:56 AM
Message Edited by tmadden@linkamericacorp.com on 12-21-2004 07:56 AM
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tmadden@linkamericacorp.com wrote:I'm calling a Fortran dll from Visual Basic, and I get the error message : "Bad dll Calling Convention"on the line that calls the dll.WhenI debug the program, the dll does operate on the integer, but then it gives the error. I've included all my code. This is my first attempt at a dll, so sorry in advance if its a simple question.Code:VB Form 1:
Option Explicit
Private Sub Command1_Click()
Dim I As Integer
I = 20
MsgBox (I)
SimpleFortranSub I
MsgBox (I)
End Sub
VB Module1:
Option Explicit
Declare Sub SimpleFortranSub Lib "C:dev2EXAMPLESimpleFortranSub.dll" (ByRef I As Integer)
Shouldn't the VB call the DLL with Call SimpleFortranSub(I)?
Mike D.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Shouldn't the VB code call Fortran with Call SimpleFortranSub(I)?
Mike D.
Message Edited by durisinm on 12-21-2004 07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for taking a look. I believe either method should work fine.
From the VB6 Help Files:
"There are two ways to call a Sub procedure:
' Both of these statements call a Sub named MyProc. Call MyProc (FirstArgument, SecondArgument) MyProc FirstArgument, SecondArgumentNote that when you use the Call syntax, arguments must be enclosed in parentheses. If you omit the Call keyword, you must also omit the parentheses around the arguments. "
Message Edited by tmadden@linkamericacorp.com on 12-21-200407:45 AM
Message Edited by tmadden@linkamericacorp.com on 12-21-2004 07:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mod: Private i As Integer Declare Sub Fadd Lib "C:dev2FCallF.dll" (i As Integer) Form: Private Sub Command1_Click() Dim iVB As Integer iVB = 20 Fadd iVB MsgBox (iVB) End Sub Fortran DLL: subroutine Fadd(i) !DEC$ ATTRIBUTES DLLEXPORT, Alias: "Fadd" :: Fadd !DEC$ ATTRIBUTES STDCALL :: Fadd Integer*2 i !DEC$ ATTRIBUTES REFERENCE :: i i=i+1 end subroutine Fadd
Message Edited by tmadden@linkamericacorp.com on 12-21-2004 11:25 AM

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page