Fortran/Visual Basic Mixed-Language Programs

Visual Fortran and Visual Basic mixed-language programs typically use:

In Fortran/Visual Basic programs, the Visual Basic must be 32-bit (at least Version 5.0). You can also use the Visual Basic for Applications (VBA) included with Microsoft Excel to call Fortran subprograms.

The Visual Basic development environment is separate from the Visual Fortran Version 6 development environment. However, the two languages can coexist in the same final application.

The usual case is to call Fortran subprograms from Visual Basic. Because Visual Basic subprograms are interpreted and not compiled, they cannot be called directly from compiled language programs like Fortran. Instead, Visual Basic creates OLE objects that export properties and routines.

It is also possible for Visual Basic to pass the address of its procedures to a Fortran program, to be called later by that Fortran program as callbacks. Refer to the Visual Fortran Sample in the ...\DF98\SAMPLES\MIXLANG\VB\CALLBACK folder for an example of Visual Fortran calling Visual Basic callback routines.

When calling a Fortran subprogram from Visual Basic, you need to:

  1. Create the Visual Fortran subprogram as a Fortran DLL project
  2. Reference the DLL from Visual Basic with a Declare Sub or Declare Func statement

The following sections discuss Visual Basic calling a Fortran DLL subprogram: