Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28381 Discussions

can't get value correctly from fortran dll to VB.net back

Lu_Zhang
Beginner
291 Views

Hi Everyone,

I can't make the following code working in VS2015 with IVF, though it is very simple. Value C from dll is always 0, not 6.0 as expected. Thanks so much.

//my VB code:

Public Class Form1
    Public Declare Sub DLL_ROUT Lib "D:\Debug\Dll2.dll" _
    (ByVal A As Double, ByVal B As Double, ByVal C As Double)
    Public Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim A As Double
        Dim B As Double
        Dim C As Double
        A = 2.0
        B = 3.0
        Call DLL_ROUT(A, B, C)
        Button1.Text = C
    End Sub
End Class

 

// my Fortran  dll code:

SUBROUTINE DLL_ROUT (A, B, C)
IMPLICIT NONE
! Specify that DLL_ROUT is exported to a DLL
! and that the external name is 'DLL_ROUT'
!DEC$ ATTRIBUTES DLLEXPORT, STDCALL :: DLL_ROUT
!DEC$ ATTRIBUTES ALIAS:'DLL_ROUT' :: DLL_ROUT

DOUBLE PRECISION A, B, C

C = A * B
RETURN
END

 

 

 

0 Kudos
2 Replies
Juergen_R_R
Valued Contributor I
291 Views

This looks more like a problem for the Windows Forum, and not for the Linux/MACOSX Forum.

 

0 Kudos
Lu_Zhang
Beginner
291 Views

sorry, wrong forum

0 Kudos
Reply