大师指点:DLL的参数为一个回调函数,VB6可以,VB2005不行。该怎么解决
大师指点:DLL的参数为一个回调函数,VB6可以,VB2005不行。
Public Function BackCallFun(ByVal a As Integer, ByVal b As Integer) As Integer
...
...
End Function
dll申明:
Public Declare Function SetCallBack Lib "DIVERS.dll" (ByVal nBackCallFun As Integer) As Integer
vb6:
dim nResult as integer
nResult = SetCallBack(AddressOf BackCallFun)
成功
vb2005:
dim nResult as integer
nResult = SetCallBack(AddressOf BackCallFun)
“AddressOf”表达式不能转换为“Integer”,因为“Integer”不是委托类型。
请教大虾指点!谢谢!
------解决方案--------------------
Public Delegate Function BackCallFunDelegate(ByVal a As Integer, ByVal b As Integer) As Integer
Public Function BackCallFun(ByVal a As Integer, ByVal b As Integer) As Integer
End Function
Public Declare Function SetCallBack Lib "DIVERS.dll" (ByVal nBackCallFun As BackCallFunDelegate) As Integer
Dim nResult As Integer
nResult = SetCallBack(New myDelegate(AddressOf BackCallFun) )
Public Function BackCallFun(ByVal a As Integer, ByVal b As Integer) As Integer
...
...
End Function
dll申明:
Public Declare Function SetCallBack Lib "DIVERS.dll" (ByVal nBackCallFun As Integer) As Integer
vb6:
dim nResult as integer
nResult = SetCallBack(AddressOf BackCallFun)
成功
vb2005:
dim nResult as integer
nResult = SetCallBack(AddressOf BackCallFun)
“AddressOf”表达式不能转换为“Integer”,因为“Integer”不是委托类型。
请教大虾指点!谢谢!
------解决方案--------------------
Public Delegate Function BackCallFunDelegate(ByVal a As Integer, ByVal b As Integer) As Integer
Public Function BackCallFun(ByVal a As Integer, ByVal b As Integer) As Integer
End Function
Public Declare Function SetCallBack Lib "DIVERS.dll" (ByVal nBackCallFun As BackCallFunDelegate) As Integer
Dim nResult As Integer
nResult = SetCallBack(New myDelegate(AddressOf BackCallFun) )