Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Event and delegate from C# to VB.NET

Event and delegate from C# to VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sri_0099
    wrote on last edited by
    #1

    Hi, i have below short code in C# public delegate void MsgEventHandler(object sender, ChatEventArgs e); public static event MsgEventHandler ChatEvent; private void Message(ChatEventArgs e) { MsgEventHandler temp = ChatEvent; if (temp != null) { foreach (MsgEventHandler handler in temp.GetInvocationList()) { handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null); } } } and when we translate in vb.NET Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs) Public Shared Event ChatEvent As MsgEventHandler Private Sub EmergencyMessage(ByVal e As ChatEventArgs) Dim temp As MsgEventHandler = ChatEvent If temp <> Nothing Then For Each handler As MsgEventHandler In temp.GetInvocationList() handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing) Next End If End Sub but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event. can u help me to figure it out from c# to vb.net? thank you regards Sri

    C N 2 Replies Last reply
    0
    • S sri_0099

      Hi, i have below short code in C# public delegate void MsgEventHandler(object sender, ChatEventArgs e); public static event MsgEventHandler ChatEvent; private void Message(ChatEventArgs e) { MsgEventHandler temp = ChatEvent; if (temp != null) { foreach (MsgEventHandler handler in temp.GetInvocationList()) { handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null); } } } and when we translate in vb.NET Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs) Public Shared Event ChatEvent As MsgEventHandler Private Sub EmergencyMessage(ByVal e As ChatEventArgs) Dim temp As MsgEventHandler = ChatEvent If temp <> Nothing Then For Each handler As MsgEventHandler In temp.GetInvocationList() handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing) Next End If End Sub but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event. can u help me to figure it out from c# to vb.net? thank you regards Sri

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I think if you google Raise Event, you'll see the correct syntax.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • S sri_0099

        Hi, i have below short code in C# public delegate void MsgEventHandler(object sender, ChatEventArgs e); public static event MsgEventHandler ChatEvent; private void Message(ChatEventArgs e) { MsgEventHandler temp = ChatEvent; if (temp != null) { foreach (MsgEventHandler handler in temp.GetInvocationList()) { handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null); } } } and when we translate in vb.NET Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs) Public Shared Event ChatEvent As MsgEventHandler Private Sub EmergencyMessage(ByVal e As ChatEventArgs) Dim temp As MsgEventHandler = ChatEvent If temp <> Nothing Then For Each handler As MsgEventHandler In temp.GetInvocationList() handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing) Next End If End Sub but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event. can u help me to figure it out from c# to vb.net? thank you regards Sri

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Two ways to get the correct syntax. 1 - Read the documentation or search with the error message. 2 - Compile your C# application, open the assembly using reflector and change language to VB.NET. :)

        Navaneeth How to use google | Ask smart questions

        S 1 Reply Last reply
        0
        • N N a v a n e e t h

          Two ways to get the correct syntax. 1 - Read the documentation or search with the error message. 2 - Compile your C# application, open the assembly using reflector and change language to VB.NET. :)

          Navaneeth How to use google | Ask smart questions

          S Offline
          S Offline
          sri_0099
          wrote on last edited by
          #4

          Thanks Navneeth, Can you please expline how to do this. I am new to vb.net. Please.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups