- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With the announcement by compaq of the educational offering for students I'm writing a new set of examples looking at mixed language programming with visual basic calling fortran dlls with i/o. I've had a rummage around the compaq site and couldn't find any examples doing this. does anyone have any pointers? The simple example I've written blows up at the fist bit of i/o in the fortran dll, i.e. vb calling fortran. i've had no difficulty with vb calling functions and subroutines, with scalar and array arguments and no i/o.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mixed-language I/O is usually a bad idea. In this case, the Fortran DLL is trying to write to the console, which doesn't exist. You can add a call to AllocConsole to create a console, or use MessageBox. In general, you'd be better served by passing in a VB callback routine that the Fortran code can call to display output to the user's window.
Steve
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks steve. what i actually wanted to do was show the students was how to read and write data via files in fortran, i.e. set up a vb front end and then get things all done in fortran. is this possible? if so could you give me some idea where to look in the on-line documentation. i don't mind rummaging around if i've got somewhere to start.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I/O to files works fine. Just don't try to access the console (unit *, etc.) You don't need to do anything special here.
We have VB examples, including on our web site. Read the mixed-language programming chapter - the biggest problem VB users have is omitting the ALIAS attribute which is needed to get the exported name to match what VB expects.
Steve
We have VB examples, including on our web site. Read the mixed-language programming chapter - the biggest problem VB users have is omitting the ALIAS attribute which is needed to get the exported name to match what VB expects.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure of the exact details, but basically you pass the address of a VB routine in the argument list when calling the Fortran routine. In Fortran, this argument is declared EXTERNAL. When the Fortran code wants to call the callback, it just calls it by the name in the argument list. You do have to make sure that the arguments you supply are what the routine expects.
I've never done this myself, so don't have an example handy.
Steve
I've never done this myself, so don't have an example handy.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've developed a proof-of-concept that uses a Visual Basic front end program calling a Fortran DLL that updates a progress bar (in the front-end) via a callback. Took longer to work out the VB end than it did to get the Fortran working. If you'd like to see the example, I can zip the VB and CVF projects and send them to you; just drop me an email at carmanj@jsc.mil.
Steve - you can do likewise if you'd like to keep a copy for future reference. I've also got a similar proof-of-concept that demonstrates the generic function and dynamic allocation (using pointers) features of F90 available. Just let me know
John Carman
Steve - you can do likewise if you'd like to keep a copy for future reference. I've also got a similar proof-of-concept that demonstrates the generic function and dynamic allocation (using pointers) features of F90 available. Just let me know
John Carman

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