locked
forum for visual basic language? RRS feed

  • Question

  • Hi!

    where is the forum for the following question:
    VB Fortran DLL
    which category and forum?


    I try to understand how to use a fortran function (which is in a dll) from VB.
    Actually I want to use vb as interface.
    I the VB 2008 express form I have 2 textbox and a button.
    I enter a  number in the top textbox and once the button is pushed, this number should be multiplied by 23 and should appear in the bottom textbox...
    here is my VB code:
    Public
     Class
     Form1

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim k, l As Integer
    k = TextBox1.Text
    l = somme(k)
    TextBox2.Text = l
    End Sub
    End Class
    Module global1

    Declare Function somme Lib "C:\test\beware.dll" (ByVal r As Integer ) As Double

    End Module

    and my fotran code (I use CVF):
    integer function somme(a)
    !DEC$ATTRIBUTES STDCALL :: somme
    !DEC$ATTRIBUTES DLLEXPORT:: somme
    !DEC$ATTRIBUTES REFERENCE:: a
    !DEC$ATTRIBUTES ALIAS: 'somme'::somme

    integer::a
    integer i
    i=a*23
    somme=i
    return
    end
    but I have an error and I can't manage to fix it yet.
    "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

    Could you help me?

    Thanks
    Tuesday, July 14, 2009 6:13 PM

Answers

All replies