Original Post
I'm trying to convert some C# event handling code to VB.NET using the online converters but they are not converting it correctly and I tried a few different ones.
Converts to
Here are the errors I'm getting. I have searched over the web and tried different things but nothing works (for example I tried m_ctrl.BeginInvoke(New PacAttachedDelegate(AddressOf OnPacAttached), id))
Error 1 End of statement expected.
Error 2 End of statement expected.
Error 3 'Public Event OnPacAttached(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Error 4 'Public Event OnPacAttached(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Error 5 'Public Event OnPacRemoved(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
public event PacAttachedDelegate OnPacAttached = null;
public event PacRemovedDelegate OnPacRemoved = null;
void PacAttachedCallback(int id)
{
m_numDevices++;
if (OnPacAttached != null)
m_ctrl.BeginInvoke(OnPacAttached, id);
}
void PacRemovedCallback(int id)
{
m_numDevices--;
if (OnPacRemoved != null)
m_ctrl.BeginInvoke(OnPacRemoved, id);
}Converts to
Public Event OnPacAttached As PacAttachedDelegate = Nothing
Public Event OnPacRemoved As PacRemovedDelegate = Nothing
Private Sub PacAttachedCallback(id As Integer)
m_numDevices += 1
If OnPacAttached IsNot Nothing Then
m_ctrl.BeginInvoke(OnPacAttached, id)
End If
End Sub
Private Sub PacRemovedCallback(id As Integer)
m_numDevices -= 1
If OnPacRemoved IsNot Nothing Then
m_ctrl.BeginInvoke(OnPacRemoved, id)
End If
End SubHere are the errors I'm getting. I have searched over the web and tried different things but nothing works (for example I tried m_ctrl.BeginInvoke(New PacAttachedDelegate(AddressOf OnPacAttached), id))
Error 1 End of statement expected.
Error 2 End of statement expected.
Error 3 'Public Event OnPacAttached(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Error 4 'Public Event OnPacAttached(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Error 5 'Public Event OnPacRemoved(id As Integer)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.