Resolved “ addressof ” VB6 to VB.NET

johan_

New member
Joined
Mar 15, 2010
Messages
2
Programming Experience
1-3
Hello, I´m having some problem to convert my VB6 project to VB.NET
I dont understan how this "addressof" function should be in VB.NET


My VB6 code:

Declare Function MP4_ClientStart Lib "hikclient.dll" (pClientinfo As CLIENT_VIDEOINFO, ByVal abab As Long) As Long

Public Sub ReadDataCallBack(ByVal nPort As Long, pPacketBuffer As Byte, ByVal nPacketSize As Long)

If Not bSaved_DVS Then
bSaved_DVS = True
HW_OpenStream hChannelHandle, pPacketBuffer, nPacketSize
End If
HW_InputData hChannelHandle, pPacketBuffer, nPacketSize

End Sub



nn1 = MP4_ClientStart(clientinfo, AddressOf ReadDataCallBack)



-------------------------------------

its not the complete code, just everything that has with the addressof function to do
 
Last edited:
AddressOf in .Net is pretty much just followed by the name of a sub. For example when using the AddHandler:
VB.NET:
AddHandler Control.Event, AddressOf SubroutineThatHandlesIt
In your case it looks like you're delegating the call of the function in the MP4_ClientStart() parameter to call the ReadDataCallBack() function, I'm not seeing where you're passing any parameters to it though.
 
done

it´s working now

I did it like this

VB.NET code:

Declare Function MP4_ClientStart Lib "hikclient.dll" (ByRef pClientinfo As CLIENT_VIDEOINFO, ByVal abab As ReadDataCallBackDelegate) As Integer

Public Delegate Sub ReadDataCallBackDelegate(ByVal nPort As Long, ByRef pPacketBuffer As Byte, ByVal nPacketSize As Long)

Public Sub ReadDataCallBack(ByVal nPort As Integer, ByRef pPacketBuffer As Byte, ByVal nPacketSize As Integer)
If Not bSaved_DVS Then
bSaved_DVS = True
HW_OpenStream(hChannelHandle, pPacketBuffer, nPacketSize)
End If
HW_InputData(hChannelHandle, pPacketBuffer, nPacketSize)
End Sub


MP4_ClientStart(clientinfo, AddressOf ReadDataCallBack)
 
Back
Top