0

I have a C# line of code I want to translate to VB.net It is:

job.StateChanged += new  EventHandler<JobStateChangedEventArgs>(StateChanged);

I know how to do this:

 AddHandler job.StateChanged, AddressOf StateChanged

But that seems to leave out the type of argument (JobStateChangedEventArgs) that C# is able to express.

Help is appreciated.

  • But `job.StateChanged` provides the `JobStateChangedEventArgs` when the event is raised. `StateChanged` is just the event handler. – Tim Schmelter Nov 09 '13 at 21:15
  • I don't see the exact point of the original C# code. The most logical version would be: `job.StateChanged += new EventHandler(StateChanged);`. Other thing is declaring an event: `event EventHandler myEvent;` and then using it in the assignation: `job.StateChanged += myEvent;`. If you do everything in "one go", you don't need the `` bit (for what? You can only attach to `.StateChanged` the supported event). Same thing for `AddressOf` (with `Option Strict On`): you can attach only the right event and thus this bit is not necessary. – varocarbas Nov 09 '13 at 21:29

0 Answers0