- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe this is a very beginer-level question.
{As very neatly shown by the recent post (http://software.intel.com/en-us/forums/showthread.php?t=54555), one can successfully call VB from Fortran. Many thanks to Dmitri/ForAll for that! }
I believe when Fortran calls a VB subroutine with array as an argument, I need to pass a pointer to the array may be along with its length. Then on VB side I will need to "reconstruct" the array. Does that sound right? Is there a sample somewhere? In the Intel Fortran documentation, I could found VB calling Fortran; may be I didn't looked at the correct place.
Specifically, what I am looking for is
Fortran:-
Program Test
Implicit None
Integer :: A(10)
Call Method_In_VB(A)
End Program Test
VB:-
Public Class
Public Sub Method_In_VB(ByRef A)
' Some operations on A
End Sub
End Class
Abhi
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
Thanks.
But I am struggling with passing an array "from" Fortran "to" VB. I have created a VB type library and used Fortran Module Wizard to access it on the Fortran side. I believe my interfaces with VB are working fine since I can pass the scalar arguments to VB and launch the required forms etc.
I can create the SafeArrays in Fortran but when I try to pass them to VB these do not work. I am missing something.
Is there some sample code that shows how to do it?
Sincerely
Abhijit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, you're trying to go through the COM interface - that is very different. Unfortunately, it's not a topic I am well versed in. I think the way it works is that you would pass an ordinary Fortran array and the COM interface layer would convert that as needed.
I don't have any samples of doing this. I know that some users here are more versed in COM and may be able to help/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AnthonyRichards
The attached zip file has 4 fortran files and 1 vb file. I did following:-
(1) The vb file ComTrial.vb is COMclass file created in VB project. This should create a type library named "Test_FortranCallsVB.tlb".
(2) I used the Fortran Module Wizard on this file and generated module file "Test_FortranCallsVB.f90".
(3) The 4 fortran files are included in a Fortran consol project. The module file COMSetup encapsulates initialization of a COM object using program ID while in the module file SafeArray I have made an attempt to create variant array from fortran array.
Currently, when I run the fortran program, the _scalar method works fine. However, nothing happens with the _array method. If I try to pass the variant array, I (correctly) get a type mis-match compile time error.
Sincerely
Abhi

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