BC30577: '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
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
Make sure the argument is a method name.
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for