Silverfrost Forums

Welcome to our forums

VB-6 Array call a FTN95 Fortran.dll

18 Apr 2007 8:31 #1863

Hallo all We trey to make a fortran.dll and called from VB-6 Since we are not a very experienced fortran-programmer,i need some help This example program as test program for a bigger array routine with two arguments ,but i callecd a runtime Error all ready Error'453' Can't find dll entry point on subarray on C:\john........\subarray2.dll I think that the problem are the lenght of the array and how to pass it to the fortran.dll ,it's make no difference of we pass this lenghts also as a argument to the fortran.dll We do some think wrong .

The vb-6 code are Private sub Command1_click() Dim X( 1 to 10 ) as integer Dim N as Integer Dim R as Integer N = 10 For I =1 to 10 X(I) =I next I Call Subarray2 (X(1) , R ) text1.text = str$ (R) end sub On a module Declare sub SUBARRAY lib'C:\jan.......subarray2.dll\X as Integer,R as Integer

On Fortran FTN95 with the F_ STDCALL as extra compiler options Subroutine SUBARRAY(Arr,R) Integer(kind=3):: Arr(:) Integer(kind=3)::R Integer(kind=3)::J R=0.0 j=10 Do j= I R=R+ Arr( J ) End do End subroutine

I would be very pleased for any help john

18 Apr 2007 12:12 #1865

Initially I would recommend using F_STDCALL in the code as in the KBase of this forum under 'Calling a Salford FTN95 DLL from Microsoft Visual Basic'. See also in the help file under Win32 platform->Mixed language programming->Calling an FTN95 DLL from Visual Basic.

Your initial tests should use a simple scalar variable passed ByRef. When moving to arrays, make sure the elements of the same size in VB and FTN95.

FTN95 arrays are stored contiguously in 'column major' ordering. I do not remember if VB 6 arrays are contiguous. They could be 'safe arrays' with a header as in .NET. If the arrays have more than one dimension then the ordering could be wrong.

18 Apr 2007 4:46 #1867

FYI

VB 6 arrays unlike VB.NET array are native and have no header.

Carl

19 Apr 2007 8:53 #1871

OK paul it's works so far ,i change the integer(kind=3) to integer(kind=2) and so far so good,but found a new problem Can I debug a FTN95.dll within a vb-6 project?? Or is it only possible on dot.net configuration ?? greatings john

19 Apr 2007 4:40 #1873

VB arrays are safe arrays. They run contiguous in memory. You can find information about them here: http://msdn2.microsoft.com/en-us/library/ms221145.aspx

Whether you can debug your Fortran DLL with SDBG depends on what your VB6 program does. In general if you make a .exe with VB and then do

sdbg vbprog.exe

You should be able to debug your DLLs.

28 Feb 2009 2:16 #4345

Hi Re calling a fortran dll from VB6. I would like to know the final outcome of this post. I get exactly the same error 453 message. I am new to FORTRAN and so not sure what it means by 'cant find entry point' Have worked for some time on this now and working through the previous posts does not sort the problem out. Does some one have an example of a fully working portion of code that I can try out to see where I am going wrong. many thanks

David

Quoted from john62 Hallo all We trey to make a fortran.dll and called from VB-6 Since we are not a very experienced fortran-programmer,i need some help This example program as test program for a bigger array routine with two arguments ,but i callecd a runtime Error all ready Error'453' Can't find dll entry point on subarray on C:\john........\subarray2.dll I think that the problem are the lenght of the array and how to pass it to the fortran.dll ,it's make no difference of we pass this lenghts also as a argument to the fortran.dll We do some think wrong .

The vb-6 code are Private sub Command1_click() Dim X( 1 to 10 ) as integer Dim N as Integer Dim R as Integer N = 10 For I =1 to 10 X(I) =I next I Call Subarray2 (X(1) , R ) text1.text = str$ (R) end sub On a module Declare sub SUBARRAY lib'C:\jan.......subarray2.dll\X as Integer,R as Integer

On Fortran FTN95 with the F_ STDCALL as extra compiler options Subroutine SUBARRAY(Arr,R) Integer(kind=3):: Arr(:) Integer(kind=3)::R Integer(kind=3)::J R=0.0 j=10 Do j= I R=R+ Arr( J ) End do End subroutine

I would be very pleased for any help john

28 Feb 2009 11:53 #4347

There is some information in the KBase article in this forum under the heading 'Calling a Salford FTN95 DLL from Microsoft Visual Basic '. This information is also in the help file FTN95.chm. You can probably ignore the bit about LibMain.

Please login to reply.