Click here to Skip to main content
16,008,954 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the following error:
"Method 'Private Sub updatetext(text As Object)' dose Not have a signature compatible with delegate Delegate Sub MethodInvoker()"

Please Help Me.
-----------my code------------------
VB
Public Sub search()
        Try

            cmdoledb.CommandText = "SELECT NAME FROM table1 WHERE ID=" & CInt(txtid.Text)
            cmdoledb.CommandType = CommandType.Text
            cmdoledb.Connection = cnnoledb
            Dim rdroledb As OleDbDataReader = cmdoledb.ExecuteReader
            While rdroledb.Read = True
                updatetext(rdroledb.Item(0).ToString)
                Thread.Sleep(2000)
                tictac()
            End While
            t1.Abort()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        cmdoledb.Dispose()
    End Sub
    Private Sub updatetext(ByVal text)
        If Me.InvokeRequired Then
            Me.Invoke(New MethodInvoker(AddressOf updatetext),New Object(){text})        
Else
        txtnam.Text &= text
        End If
    End Sub
Posted
Updated 19-May-10 19:35pm
v2
Comments
Sandeep Mewara 20-May-10 1:36am    
As the error suggests check for the signature!

1 solution

The MethodInvoker is a generic Delegate with no arguments (signature). If you want to pass arguments to a delegate then you need to create your own Invoker Delegate Like this :

VB.NET
Private Delegate Sub UpdateTextInvoker(ByVal MyText As String)'Create your own Invoker Delegate 

    Private Sub UpdateText(ByVal MyText As String)

        If Me.InvokeRequired Then
            Me.Invoke(New UpdateTextInvoker(AddressOf UpdateText), New String() {MyText})'Call your custom invoker
        Else
            txtName.Text = MyText
        End If

    End Sub

Hope this helps

Happy Coding
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900