Silverfrost Forums

Welcome to our forums

Problem calling Fortran from VB6

23 Sep 2011 9:36 #9014

Hi,

This is embarrassing because I took some working code that passed arrays back and forth between vb6 and Fortran and I broke it. In an effort to debug the problem I ended up eliminating all passed variables, but it still doesn’t work. I am beyond mystified. Help!

The Fortran subroutine executes fine when called from another Fortran routine, however, when I call it from vb it does not work. Thus I include only a little of the Fortran:

! Subroutine CALLED_FROM_VB() ! use this line when called from Fortran F_STDCALL Subroutine CALLED_FROM_VB() ! use this line when called from vb … Write a file to show the Fortran worked …

------------------------ vb code:

Module level stuff:

Option Explicit Private Declare Sub CALLED_FROM_VB Lib 'C:\TurboVision\Design_System\Library\AIRFOIL_CALC.dll' () …

In subroutine: … Call CALLED_FROM_VB …

Both AIRFOIL_CALC and salflibc DLLs are at the location specified in the declare statement

----------------- Computer configuration:

PC running Vista office edition 64 bit SP2

Silverfrost FTN95 Version: 5.50 License: FULL

------------------------Compiler Stuff

Switches /IGNORE 179 684 /FPP Output filename Release\Win32\AIRFOIL_CALC.dll Output filetype DLL Preprocess source files is checked Linker Options - Export all is checked

Any help would be appreciated. I have spent most of a day on this apparently trivial problem

Regards, Kent

24 Sep 2011 7:04 #9015
  1. Have you read the help information on this topic in ftn95.chm and on this forum?

  2. Is your DLL 'visible' to your VB (i.e. does it access the DLL)?

26 Sep 2011 12:28 #9024

Hi Paul,

Yes, I believe I have read all the help info available, several times.

Yes, the DLL appears to be visible - I don't get any error when calling the subroutine.

More info - when I was passing several arrays, Excel crashed as soon as I called the DLL. After I eliminated the arguments Excel did not crash, but the DLL did not execute (it writes a one line file). The DLL did execute properly when I called it from Fortran (after, of course, changing the subroutine first line back to the standard Fortran callable version)

Thanks, Kent

Please login to reply.