I've been out of the loop for a while and now doing some coding again.
I'm having trouble convert a particular c# snippet to vb .net. Any help would be appreciated:
public Form1()
{
// Add a listener for usb events
myUsbDevice.usbEvent += new usbDevice.usbEventsHandler(usbEvent_receiver);
}
private void usbEvent_receiver(object o, EventArgs e)
{
// Do Stuff
}
Relevant bits are:
// usbDevice Class
public delegate void usbEventsHandler(object sender, EventArgs e);
public event usbEventsHandler usbEvent;
My conversion is this:
// usbDevice Class
Public Delegate Sub usbEventsHandler(sender As Object, e As EventArgs)
Public Event usbEvent As usbEventsHandler
& this this what doesn't work (obviously):
Private Sub Form1()
myUsbDevice.usbEvent += New usbDevice.usbEventsHandler(AddressOf usbEvent_receiver) // this doesn't work. Says to use RaiseEvent although I think it should just be an AddHandler
End Sub
Private Sub usbEvent_receiver(o As Object, e As EventArgs)
// Do stuff
End Sub
I'm just not quite sure how to convert it. Just using AddHandler doesn't seem to make sense and won't either:
AddHandler myUsbDevice.usbEvent, Sub usbEvent_receiver() // am missing 'o' object and 'e' eventargs + the whole usbDevice.usbEventsHandler bit is gone and I don't think/know whether that's right.