'AddressOf' operand must be the name of a method (without parentheses)

The AddressOf operator creates a procedure delegate instance that references a specific procedure. The syntax is as follows:

AddressOf procedurename

You inserted parentheses around the argument following AddressOf, where none are needed.

Error ID: BC30577

Example

The following example generates bc30577:

Public Sub CountZeroToTen()
    For i = 0 To 10
        Console.WriteLine($"Counted: {i}")
        Threading.Thread.Sleep(500)
    Next
End Sub

Sub Main()
    ' Any of the following two lines generates bc30577.
    'Dim t As New Threading.Thread(AddressOf(CountZeroToTen))
    'Dim t As New Threading.Thread(AddressOf CountZeroToTen())
    t.Start()
End Sub

To correct this error

  1. Remove the parentheses around the argument following AddressOf as shown in the following example:

    Public Sub CountZeroToTen()
        For i = 0 To 10
            Console.WriteLine($"Counted: {i}")
            Threading.Thread.Sleep(500)
        Next
    End Sub
    
    Sub Main()
        Dim t As New Threading.Thread(AddressOf CountZeroToTen)
        t.Start()
    End Sub
    
  2. Make sure the argument is a method name.

See also