kcwallace Posted April 25, 2006 Posted April 25, 2006 I have a routine in my application that builds a form on the fly from input from a database. Everything works great. I have added another form that is also created on the fly, and it too works great. The thing this is, the code is nearly identical to build each form. I can easily write a routine to build generically build a form. However, I need to add buttons that require events. What I would like to know if anyone knows how to pass a delegate/routine as a parameter of a routine so addHandler can use it. Quote Go Beavs!!!
Leaders snarfblam Posted April 25, 2006 Leaders Posted April 25, 2006 Public Sub Example() 'Get function pointer Dim myDelegate As EventHandler = AddressOf SomeForm.Button1_Click 'Pass it to a function MoreExample(myDelegate) End Sub Public Sub MoreExample(ByVal Handler As EventHandler) 'Accept function pointer and use it AddHandler Button1.Click, Handler End Sub Quote [sIGPIC]e[/sIGPIC]
kcwallace Posted April 25, 2006 Author Posted April 25, 2006 Thank you very much. My code just got much simpler Quote Go Beavs!!!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.