views:

243

answers:

1

Is it possible to hook up an event to another event in VB8? I have this code in C#...

public event ShowAboutDialog = delegate {};
private void hookupEvents() {
  myButton.Click += ShowAboutDialog;
}

And am trying to convert it into VB8, but can't get it to work..

Public Event ShowAboutDialog As EventHandler
Private Sub HookupEvents()
    AddHandler AboutMenuItem.Click, AddressOf ShowAboutDialog
End Sub

Thanks!

+1  A: 

You just need to pass the name of the event handler routine after AddressOf

Private Sub HookupEvents()
    AddHandler AboutMenuItem.Click, AddressOf ShowAboutDialog
End Sub

Public Sub ShowAboutDialog(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub
rip
Is this the only way to do it in VB? Is there no way to hook the AboutMenuItem.Click event to another event, without using a routine?
devghost