To create a DLL that will work with Microsoft Visual Basic, take Fortran source (without a main program) and indicate the procedures that you want available in the DLL with the DLL_EXPORT statement, then invoke the LF95 driver like this:
LF95 source.f90 -win -dll -ml msvbIn your BASIC code, a procedure's declaration will be like one of the following examples:
(see the relevant section below if an item on the argument list is either an array or is character datatype). Note that in the example above, "my_dll" must specify a complete path in order to operate within the Visual Basic Environment.
Character arguments are passed as strings with the length of each string appended at the end of the argument list.
Character (string) arguments and hidden length arguments must be passed by value, i.e., declare the procedure's arguments (actual and hidden) with the ByVal keyword. Refer to the example VBDEMO program. The following restrictions apply:
When passing an array from Microsoft Visual Basic you will need to declare the argument as a scalar value in the Basic declaration, and pass the first element of the array as the actual argument. Declare the array dummy argument normally in the Fortran procedure. Note that the default lower bound for arrays in Visual Basic is 0, so you may find it helpful to explicitly declare your Fortran arrays with a lower bound of 0 for each dimension, or explicitly declare your Basic arrays to have a lower bound of 1 (this can be done at the module or procedure level via the Option Base statement). Note also that arrays of strings cannot be passed from Visual Basic to LF95.