Fortran/Visual Basic Calling Conventions

You establish Fortran subroutines and functions in Visual Basic forms and the Fortran routines are then invoked from a Basic module. A Fortran routine has to be a DLL (dynamic-link library) to be called from Basic. For more information on DLLs, see Fortran Dynamic-Link Library Projects and Creating Fortran DLLs.

The calling-convention ALIAS directive (or ATTRIBUTES property ALIAS) is needed if mixed-case names are to be preserved (by default Fortran translates names to all uppercase). However, two special cases require different treatment:

The following Fortran and Visual Basic statements establish an example Fortran function to be called from Basic:

!  Fortran Subprogram establishing Fortran function.
       INTERFACE
          DOUBLE PRECISION FUNCTION GetFVal (r1)
             !DEC$ ATTRIBUTES ALIAS:'GetFVal' :: GetFVal
             !DEC$ ATTRIBUTES VALUE :: r1
             REAL r1
          END FUNCTION
       END INTERFACE

'FORM.FRM Basic Form to establish Fortran function
Declare Function GetFVal Lib "C:\f90\FVAL.DLL" (ByVal r1 As Single) As Double