Declare Function EnableWriteNotification Lib "WtOPCSvr" Alias "_EnableWriteNotification@8" (ByVal Callback As Long, ByVal ConvertToNative As Long) As Long
Sub MyWriteCallback(ByVal Itemhandle As Long, ByRef newValue As Variant, ByRef DeviceError As Long)
'函数内代码省略
End Sub
EnableWriteNotification(AddressOf MyWriteCallback, True)
这是VB6的程序。现在改为Vb.net出错,意思是EnableWriteNotification需要的参数是long型。不支持Address of。如何解决?
------解决思路----------------------
Public Delegate Sub WriteCallback(ByVal Itemhandle As Long, ByRef newValue As Object, ByRef DeviceError As Long)
Declare Function EnableWriteNotification Lib "WtOPCSvr" Alias "_EnableWriteNotification@8" (ByVal Callback As WriteCallback, ByVal ConvertToNative As Long) As Long
Public Sub MyWriteCallback(ByVal Itemhandle As Long, ByRef newValue As Object, ByRef DeviceError As Long)
End Sub
EnableWriteNotification(AddressOf MyWriteCallback, True)
又:VB6 的4自己 Long,在 VB.Net 中应该是 Integer。你的类型正确否?