title: AddressOf in Visual Basic .NET
body: <p>I have buttons generated through code (dynamically). I have to associate an event (the same) to them. I use <code>AddHandler button.click, AddressOf mysub</code>.</p>
  
  <p>The issue is that mysub gets a string (<code>mysub(string</code>)), but AddressOf doesn't accept a parameter inside the routine. How can I do this? Using also an alternative to AddressOf.</p>
  
  <pre><code>Public Class Form1
  
     ...
  
     Private Sub mysub(ByVal sender As Object, ByVal e As System.EventArgs, ByVal str As String)
        ...
        ...
     End Sub
  
     ...
  
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
        ...
  
        While something
           ...
           Dim btn As New Button
           ...
           AddHandler btn.click, AddressOf mysub 'here the issue
        End While
  
        ...
  
     End Sub
  End Class
  </code></pre>