This sample demonstrates how to call a Fortran DLL from Visual BASIC.NET and how to pass simple arguments.
.sln
file"VBCallsFortran"
" is not shown in boldface type in the Solution Explorer,
right-click on project ""VBCallsFortran"
" and select "Set as StartUp Project
".
Build > Clean Solution
Build > Build Solution
Debug > Start Without Debugging
or press Ctrl-F5
A "Do It"
button will be displayed along with four input values. Click the button. The VB code will call the Fortran routine DLL_ROUT
and pass it a double precision real input array, a string, and a double-precision output array. The Fortran code uses an internal READ
to convert the string to a number, multiplies it by the values in the input array, and then stores the result in the output array.
build.bat clean
build.bat release
build.bat debug
VBCallsFortran
in Visual Studio IDEFcall.dll
built from above steps under directory .\debug
or .\release
to the VB project output folder VBCallsFortran\bin\Debug
or VBCallsFortran\bin\Release
VBCallsFortran\bin\Debug\VBCallsFortran.exe
or VBCallsFortran\bin\Release\VBCallsFortran.exe
from the command window"VBCallsFortran"
and choose Properties. In the left column, select
"Debug" >
tab and check the box labeled "Enable native code debugging
", close the properties page to save the changes.
Form1.vb
and double-click on the Push Me
button.