E_Blue
E_Blue

Reputation: 1151

Two parameter Delegate error

I have the following code.

Delegate Sub WriteLogRtbDelegate(ByVal Texto As String, ByVal _Color As Color)


Private Sub WriteLogRTB(ByVal Texto As String, Optional ByVal TextColor As Color = Nothing)
    If Me.InvokeRequired Then
        Dim Txt As New WriteLogRtbDelegate(AddressOf WriteLogRTB)
        Me.Invoke(Txt, New Object() {Texto}, {TextColor}) '<--- Error here
    Else
    ....
    End If

In the Invoke line I get

El objeto de tipo 'System.Object[]' no puede convertirse en el tipo 'System.String'.

Something like

The object type 'System.Object[]' can't be converted in the type 'System.String'.

I don't understand what I'm doing wrong, Would you correct me please?

Upvotes: 0

Views: 28

Answers (1)

sstan
sstan

Reputation: 36523

Instead of

Me.Invoke(Txt, New Object() {Texto}, {TextColor})

You should be able to simply do:

Me.Invoke(Txt, Texto, TextColor)

Upvotes: 1

Related Questions