- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to call a VB subroutine from Fortran code.
this subroutine must be in VB Dll.
Please illustrate with a sample code.
Thanks,
Ashok
this subroutine must be in VB Dll.
Please illustrate with a sample code.
Thanks,
Ashok
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is what I am trying to also. What follows will not help very much because it does not work. But if someone knows what I am doing wrong, it should answer your question also.
In the CFV help there are some samples using the Fortran Module Wizard and COM. Following the steps there you can generate a wrapper module in Fortran toassist incalls to the (VB generated) DLL. The compiled code runs , but crashes with an access violation when trying to access the DLL. My test function was simply a VB Sub compiled as a dll project.
Public Sub Add2(InVar As Single, OutVar As Single)
OutVar = InVar + 2#
End Sub
OutVar = InVar + 2#
End Sub
Itried setting the instancing to different options - no effect.
In the fortram main program I had:
PROGRAM MAIN
USE TESTMOD
IMPLICIT NONE
INTEGER OBJREF, STAT
REAL*4 JUNKVARIN,JUNKVAROUT
CALL COMINITIALIZE(STAT)
CALL COMCreateObjectByGUID (CLSID_Add2, CLSCTX_ALL, IID__Add2, OBJREF, STAT)
JUNKVARIN=2.0
CALL $Add2_Add2(OBJREF,JUNKVARIN,JUNKVAROUT)
WRITE(6,*) JUNKVARIN,JUNKVAROUT
STOP
END
END
TESTMOD was the wrapper module generated by the wizard and was included in the build.
Thanks - have not done this much before - apologies in advance if I have violated the message board rules and etiquette in any way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I doubt that this will help solve your problem, but if I were you I wouldn't use the double-precision 2# constant in a calculation with single-precision variables. I would either make OutVar and InVar double precision or change the double-precision 2# constant to single-precision 2!.
Mike D

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page