0
votes

I am trying to use MIDI.NET in Visual Basic 2010 while it is written in C#. So I got the tip to convert it using an online converter since these languages are quitte similair to eachother. The one problem I have is this line

inputDevice.NoteOn += new InputDevice.NoteOnHandler(NoteOn);

converted to vb.net it looks like this

InputDevice.NoteOn += New InputDevice.NoteOnHandler(NoteOn)

which gives me 2 errors.

  1. 'Public Event NoteOn(msg As NoteOnMessage)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event. C:\Users\Den Houting\AppData\Local\Temporary Projects\MIDI\Form1.vb 14 9 MIDI

  2. Error 3 Delegate 'Midi.InputDevice.NoteOnHandler' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor. C:\Users\Den Houting\AppData\Local\Temporary Projects\MIDI\Form1.vb 14 82 MIDI

When trying to do something like RaiseEvent NoteOn it tells me NoteOn isn't an event.

Thanks.

1

1 Answers

2
votes

The proper syntax in VB.NET uses AddHandler to register the event

AddHandler InputDevice.NoteOn, AddressOf NoteOn

More on MSDN.