- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I am attempting to create a DLL in Visual Fortran 11.0.074, which is to be called from VB 6.0.
After much trailing around the internet, I have created code which, when the VB program is run gives the following error:
Run-time error '49':
Bad DLL calling convention.
This is often caused by incorrectly omitting or including the ByVal keyword from the Declare statement or the Call statement, as Visual Basic for Windows checks the change in the position of the stack pointer to detect this error.
However, as far as I can see, my declarations are correct.
As a precaution, rather than trust the defaults, I have explicitly defined characteristics associated with the call calling as well as elsewhere (eg REAL*4 instead of REAL), but with no success.
My DLL, called dll1forvb.dll, contains a subroutine, addup.f90, listed below:
! F_stdcall subroutine addup(x,y,z)
subroutine addup(x [value],y [value],z [reference])
!DEC$ATTRIBUTES DLLEXPORT :: addup
!DEC$ ATTRIBUTES ALIAS:'addup' :: addup
real*4 x, y, z
z = x + y
return
end
This is called from a VB routine, as listed below:
Private Declare Sub addup Lib "C:\\Program Files\\Intel\\DMIX\\dll1forvb.dll" _
(ByVal x As Single, ByVal y As Single, ByRef z As Single)
Sub Add_button_Click()
Dim A As Single
Dim B As Single
Dim C As Single
A = Val(Val1.Text)
B = Val(Val2.Text)
Call addup(A, B, C)
Output.Caption = "The result is " & Str(C)
End Sub
In addition, I have created a file, Dll1forVB.DEF, containing the following
; Dll1forVB.DEF - Module Definition file for Dll1forVB.FOR
;
LIBRARY Dll1forVB
Description 'Sample FORTRAN DLL to be called from VB'
EXETYPE WINDOWS XP
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS addup
subtract
WEP
However, I am not sure what purpose this serves.
The files dll1forvb.dll, dll1forvb.lib and Dll1forVB.DEF are all stored in C:\\Program Files\\Intel\\DMIX, which is listed in PATH in my environment variables.
Does anyone know what I am doing wrong?
Thanks,
Mark.
- Balises:
- Intel® Fortran Compiler
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
http://software.intel.com/en-us/forums/showthread.php?t=53420&o=d&s=lr
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
http://software.intel.com/en-us/forums/showthread.php?t=53420&o=d&s=lr
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Anthony,
That's exactly what I needed.
Thanks for your help,
Mark.

- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable