B
BoloBaby
OK, I've managed to clarify my question (whew).
I'll show two blocks of code - one in VB6.0 and one in VB.NET. The VB6.0
code manages to execute the callback function, the VB.NET does not. The
question is "how do I get the .NET code to execute the callback function?"
(Note - the declared function works to expose IRQs for a digital
input/output card. Not relevant, but worth knowing if you were curious.)
VB6.0 code:
'Dask.bas - module with lots of declarations
'relevant declaration
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal CardNumber
As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As Long, ByVal
message As Long, ByVal callbackAddr As Long) As Integer
'Form1 code
Private Sub Form_Load()
'superfluous code eliminated
DIO_INT1_EventMessage 0, 0, 0, 0, AddressOf BE_ReadPort
End Sub
'Module1.bas module that contains BE_ReadPort
Function BE_ReadPort() As Long
'this fires properly when I press an electrical switch to send digital
input to the card
MsgBox("Bang!")
End Function
* * * * *
VB.NET code:
'DIOCard.vb - wrapper class
Public Class DIOCard
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal
CardNumber As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As
Long, ByVal message As Long, ByVal callbackAddr As Form1.BP) As Integer
End Class
'Form1.vb - form code
Public Class Form1
Public Delegate Function BP() as Long
Public Function ButtonPressed() as long
'this does not go off
MsgBox("Bang!")
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'superfluous code eliminated
Dim intResult as integer
intResult = DIO_INT1_EventMessage(0, 0, 0, 0, AddressOf
ButtonPressed)
End Sub
End Class
* * * * *
That's it. Why won't the delegate function fire in .NET? No errors are
reported, the callback simply doesn't fire.
Gardner
I'll show two blocks of code - one in VB6.0 and one in VB.NET. The VB6.0
code manages to execute the callback function, the VB.NET does not. The
question is "how do I get the .NET code to execute the callback function?"
(Note - the declared function works to expose IRQs for a digital
input/output card. Not relevant, but worth knowing if you were curious.)
VB6.0 code:
'Dask.bas - module with lots of declarations
'relevant declaration
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal CardNumber
As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As Long, ByVal
message As Long, ByVal callbackAddr As Long) As Integer
'Form1 code
Private Sub Form_Load()
'superfluous code eliminated
DIO_INT1_EventMessage 0, 0, 0, 0, AddressOf BE_ReadPort
End Sub
'Module1.bas module that contains BE_ReadPort
Function BE_ReadPort() As Long
'this fires properly when I press an electrical switch to send digital
input to the card
MsgBox("Bang!")
End Function
* * * * *
VB.NET code:
'DIOCard.vb - wrapper class
Public Class DIOCard
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal
CardNumber As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As
Long, ByVal message As Long, ByVal callbackAddr As Form1.BP) As Integer
End Class
'Form1.vb - form code
Public Class Form1
Public Delegate Function BP() as Long
Public Function ButtonPressed() as long
'this does not go off
MsgBox("Bang!")
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'superfluous code eliminated
Dim intResult as integer
intResult = DIO_INT1_EventMessage(0, 0, 0, 0, AddressOf
ButtonPressed)
End Sub
End Class
* * * * *
That's it. Why won't the delegate function fire in .NET? No errors are
reported, the callback simply doesn't fire.
Gardner