-3

i have my code :

client.NotifyClientEnterView += (source, notification) => Console.WriteLine("ClientEnterView {0}: {1}", notification.Clid, notification.ClientNickname);

And i want to translate it in VB.NET (it's not working with a translator when i enter it)

I tryed AddHandler method, but it's not working (Beceause it's a eventhandler, not a event, like this : Addhandler client.NotifyClientEnterView, adressof <mysub>)

I need to translate that for execute a sub when a client enter in the channel (in teamspeak)

My library : https://github.com/Spksh/TentacleSoftware.TeamSpeakQuery

Nota : client.NotifyClientEnterView as EVENTHANDLER, not a EVENT.

I hope you understand my problem, and thank for you help.

  • Can you explain what this does currently? Also we *do not translate code* we help with actual programming issues. There are many provider's that can do this. If it is not working, explain what you have tried and where you are stuck. – Trevor Sep 16 '15 at 16:00
  • I tryed AddHandler method, but it's not working (Beceause it's a eventhandler, not a event, like this : Addhandler client.NotifyClientEnterView, adressof ) – Simon Et la famille Sep 16 '15 at 16:05
  • I suggest you add to this question. Code you have tried. What you need to achieve. Take a stab at it in VB.NET and post error, even if its a compile error. A start http://www.codeproject.com/Articles/5041/Step-by-Step-Event-handling-in-VB-NET – Devon Burriss Sep 16 '15 at 16:12
  • Thank for your link, but i already know what is a event in VB. (I written more information, refresh the page) – Simon Et la famille Sep 16 '15 at 16:18

1 Answers1

0

'AddressOf' is not used for the case of wiring a lambda to an event. So, approach the problem in 2 steps: 1. Use 'AddHandler' (as you already know) 2. Replace the C# lambda with a VB lambda using the following pattern replacement: '(..) => ..code..' -> 'Sub(..) ..code..'. e.g.,

AddHandler client.NotifyClientEnterView, Sub(source, notification) Console.WriteLine("ClientEnterView {0}: {1}", notification.Clid, notification.ClientNickname)
Dave Doknjas
  • 6,394
  • 1
  • 15
  • 28