Home > Archive > Fortran > December 2004 > DLL callback to VB6
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
DLL callback to VB6
|
|
|
| I've developed a callback example between a Fortran DLL and VB6. It
works in CVF 6.6, but fails in Lahey 7.1, where I'd prefer to keep a
large existing program. Any help would be appreciated to either
diagnose this problem or help with my actual goal of passing a line of
text to VB.
Thanks,
Mitch Heineman
Cambridge, Massachusetts
(Main languages I've programmed in: APL 1978, Fortran 1982, xBASE 1984,
VB 1995, Avenue 1999. At least Fortran's still going strong! Sure
Microsoft calls something VB.NET, but my VB6 code won't port to it.)
--------------------------------------------------------------------------
'Fortran callback to VB6. Works in CVF; causes protection faults in
Lahey
'VB6 code. Requires form with a command button and a label
'Form code
Private Sub Command1_Click()
Call Test_DLL(AddressOf Update)
End Sub
'Module code
Declare Sub Test_DLL Lib "Test_DLL" (ByVal cb As Long)
Sub Update(intPCT As Long)
'Debug.Print intPCT
frmMain.Label1.Caption = "running..." & intPCT
frmMain.Refresh
'If intPCT >= 500 Then MsgBox (intPCT)
End Sub
------------------------------------------------------
!Fortran code
Subroutine Test_DLL(update)
!first DLL line for Lahey (lf95 /win /dll /ml msvb); last two for CVF
(DF /dll)
!dll_export Test_DLL
!dec$ attributes dllexport ::Test_DLL
!dec$ attributes alias :'Test_DLL'::Test_DLL
Interface
Subroutine update(i1)
Integer i1
End Subroutine update
End Interface
Integer intPCT
Do intPCT = 1,501
Call update(intPCT)
End Do
End
| |
| Catherine Rees Lay 2004-12-15, 3:59 pm |
| I can't see anything obviously wrong, so you get my standard answer :-)
What calling convention does Lahey use by default? Is it the same as VB
is using? If you use different calling conventions, what you tend to get
is something which almost works, or which works in some cases but not
others, so it's often hard to diagnose.
[whinge mode on. Why couldn't there be something in the DLL-calling
mechanism such that when the DLL's loaded, it and the EXE compare
calling mechanisms and it howls if they're different? whinge mode off.]
I think I've seen discussions here on precisely how to do VB strings, so
it might be worth searching the archives. I will say that a) standard VB
strings and Fortran strings are very much not the same, and b) precisely
how strings are passed varies widely between Fortran compilers.
HTH,
Catherine.
In article <1102959629.540723.293030@f14g2000cwb.googlegroups.com>,
Mitch <heinemanmc@cdm.com> writes
>I've developed a callback example between a Fortran DLL and VB6. It
>works in CVF 6.6, but fails in Lahey 7.1, where I'd prefer to keep a
>large existing program. Any help would be appreciated to either
>diagnose this problem or help with my actual goal of passing a line of
>text to VB.
>
>Thanks,
>Mitch Heineman
>Cambridge, Massachusetts
>(Main languages I've programmed in: APL 1978, Fortran 1982, xBASE 1984,
>VB 1995, Avenue 1999. At least Fortran's still going strong! Sure
>Microsoft calls something VB.NET, but my VB6 code won't port to it.)
>
>--------------------------------------------------------------------------
>'Fortran callback to VB6. Works in CVF; causes protection faults in
>Lahey
>'VB6 code. Requires form with a command button and a label
>'Form code
>
>Private Sub Command1_Click()
>Call Test_DLL(AddressOf Update)
>End Sub
>
>'Module code
>Declare Sub Test_DLL Lib "Test_DLL" (ByVal cb As Long)
>Sub Update(intPCT As Long)
>'Debug.Print intPCT
>frmMain.Label1.Caption = "running..." & intPCT
>frmMain.Refresh
>'If intPCT >= 500 Then MsgBox (intPCT)
>End Sub
>------------------------------------------------------
>
>!Fortran code
>Subroutine Test_DLL(update)
>!first DLL line for Lahey (lf95 /win /dll /ml msvb); last two for CVF
>(DF /dll)
>!dll_export Test_DLL
>!dec$ attributes dllexport ::Test_DLL
>!dec$ attributes alias :'Test_DLL'::Test_DLL
>
>Interface
>Subroutine update(i1)
>Integer i1
>End Subroutine update
>End Interface
>Integer intPCT
>
>Do intPCT = 1,501
> Call update(intPCT)
>End Do
>End
>
--
Catherine Rees Lay
To email me, use my first name in front of the "at".
|
|
|
|
|