- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I tried to post this message earlier but it doesn'tlook likeI succeeded. I apologize if this try turns out to be a repetition.
I am trying to create a Fortran DLL that can be linked to routines written in Visual Basic as well as Fortran. The DLL uses allocatable arrays that are allocated and populated inside the DLL and then exports them to the calling routine. I was able to link the DLL to a Fortran main program and run it successfully. When I try to call it from a VB program, it doesn't work. My question is: Is it possible to specify a dynamic array inVB, then pass it to Fortran subroutine, allocate and populate it in the Fortran subroutine and then pass it back to VB? Is this possible at all?
I am using CVF v6.6.c. Thanks for any help.
John
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is possible using a variety of approaches. The issue has been discussed here many times since DVF first appeared. You might want to search through the forum's archieval posts to see how others have handled the task. It's not complicated but it is oblique if only because VB is COM based and deals with SAFEARRAYS while Fortran doesn't but can. BTW, dynamic arrays are to VB what allocatable arrays are to Fortran and can be exchanged subject to the vagaries of both languages' treatment of arrays.
Good Luck,
Gerry T.
Good Luck,
Gerry T.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create a com-dll in cvf (where you can do so easily using the wizid).
in the interface of your cvf dll (as designed on the com-wizid) be sure to check the assumed-size.
in vba use dim and redim to allocate arrays and pass as usual.
Also you must decide if you want in-process(faster/less crash-proof) or outta-process(slower/more crash-proof) before hand. You will be asked when you first create the com-wizid.
Finally, Don't forget the dll needs to be registered using regsvr32:
[libname].exe /REGSERVER for outta-process
regsvr32 [libname].dllfor in-process
thenin VB/A look under Tools/Ref's, and check the library for use.

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