Help with a delegate

  • Thread starter Thread starter John Wright
  • Start date Start date
J

John Wright

I have a delegate that I have defined as follows:

Public Delegate Sub myDelegate (ByVal txtBox as TextBox, byval Port as
System.IO.Ports.SerialPort)

I have a sub with the same definition. When I try to call the delegate with
an invoke I can't figure out the syntax to call it with both parameters. I
have tried:

TextBox1.Invoke(New myDelegate(AddressOf UPdateTextBox()), New Object()
{TextBox1,SerialTare})



Thinking it would work, but I can't get the signature right. I keep getting
the compiler error Argument not specified for parameter Port.

How can I write the invoke method with the correct signature to pass in both
parameters?



John
 
TextBox1.Invoke(New myDelegate(AddressOf UPdateTextBox), TextBox1,
SerialTare)

There are 2 separate parameters, not an array.
 
It shouldn't matter which way it is done, with separate parameters or
an array. The second argument to Control.Invoke is "ParamArray args()
As Object" which should accept either an array or separate parameters.

I tried the code below and it compiled OK for me.
 
Back
Top