Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

In VB? C#? I think that this question goes into syntax specific, although I think that VB and C# have similar delegate syntax.

 

If VB you do delegates like this:

'Define the delegate (return type, if function, and parameter types)
Delegate Sub MyDelegate(ByVal Value As Integer, ByVal Message As String)

Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
   'Get function pointer (delegate) to Delegadoo
   Dim G As New MyDelegate(AddressOf Delegadoo)
   
   'Call Delegadoo
   G(4, "The number after 3 is ")
End Sub

'Function we will create a pointer to
Private Sub Delegadoo(ByVal Param1 As Integer, ByVal Param2 As String)
   MessageBox.Show(Param2 & Param1.ToString)
End Sub

In other words, you pass the arguments the same way you do to a normal function. What code are you using? Or, what is the difficulty?

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...