lothos12345 Posted June 14, 2005 Posted June 14, 2005 How do I pass argurements into a function being call from a delegate? Quote
Leaders snarfblam Posted June 15, 2005 Leaders Posted June 15, 2005 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? Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.