Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29376 Discussions

Sample solution passing variables between VB, C and Fortran

Kipling__Michael
Beginner
1,373 Views

Attach is a VS 2010 sample solution.  It demonstrates how integers, reals, and character strings may be passed between Visual Basic to/from Fortran and C dll's, and to/from Fortran and C dll's as individual values and as arrays.

The program accepts 2 integers, 2 reals and 2 strings (10 characters max) as input.  It returns integer 2 output as the product integer1 and integer 2, real 2 output as the product of real 1 and real 2, and concantenates the character strings with themselves with an underscore in between.

The Fortran code probably does not use the most up-to-date methods.  Please feel free to submit new code which meets the latest standard.

The C code does not use the the latest safe functions like strcpy_s and sprintf_s.  I'm just a novice C programmer.  Again, feel free to update these C routines to the latest standard. 

Enjoy, Mike

0 Kudos
11 Replies
SergeyKostrov
Valued Contributor II
1,373 Views
Hi Mike, Thank you! >>Attach is a VS 2010 sample solution. It demonstrates how integers, reals, and character strings may be passed between >>Visual Basic to/from Fortran and C dll's, and to/from Fortran and C dll's as individual values and as arrays... Could you also upload the project archived with a classic WinZip? Unfortunately, my older WinZip can not unpack it. Thanks in advance.
0 Kudos
Steven_L_Intel1
Employee
1,373 Views

Get the free 7-Zip at http://www.7-zip.org ; More recent versions of WinZip can handle 7z files.

0 Kudos
Kipling__Michael
Beginner
1,373 Views

I would upload a .zip version, but the add files dialog does not recognize the .zip extension.

Regards, Mike

0 Kudos
SergeyKostrov
Valued Contributor II
1,373 Views
Hi Mike, >>Allowed file types: 7z avi bmp bz2 c cpp cxx doc docx f for f90 gif gz gzip h i ico icproj img jpeg jpg log m4v mov mp3 mp4 mpeg odp ods >>odt ogg pdf png pps ppt pptx sln tar tbz2 tgz txt vcproj vcxproj wmv xls xlsx zip That looks strange because zip archives are supported for upload for a long time. Yesterday I've uploaded a zip archive with some sources and everything worked. Please try again.
0 Kudos
Kipling__Michael
Beginner
1,373 Views

The "Add Files" does not recognize .zip extension or I would have used that originally.  I have uploaded the project with a .jpg extension.  Download it and change the extension back to .zip and it should work.

Regards, Mike

0 Kudos
Steven_L_Intel1
Employee
1,373 Views

Seems to work for me.

0 Kudos
Kipling__Michael
Beginner
1,373 Views

I simply can't see .zip files to select them.  I'm still working on an XP machine if it makes a difference.

The .jpg version is uploaded.

Mike

0 Kudos
Steven_L_Intel1
Employee
1,373 Views

The forum didn't properly upload your file - perhaps it got confused by a .jpg that wasn't a .jpg.  I have attached a ZIP version of your project. Thanks for providing it.

0 Kudos
SergeyKostrov
Valued Contributor II
1,373 Views
Hi Mike, Steve, Thank you and I finally have it.
0 Kudos
mohanmuthu
New Contributor I
1,373 Views

Hello Mike,

Does your code address "Fortran calling VB DLL"? This is my immediate interest.

0 Kudos
Kipling__Michael
Beginner
1,373 Views

Hi Mohanmuthu,

I have not tried calling a VB dll from Fortran.  However, I would assume that the same concepts I used would work.

Mike

0 Kudos
Reply