0

I want to find the a the name of a specific sub that I only know it's handles.

example:

Function GetSub(Handle As EventHandler) As Object
    'Help!!!
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
   TextBox1.Text = "Hello world!"
End Sub

is there a way? Thanks in advance

  • http://www.vbforums.com/showthread.php?525533-Retrieving-the-EventHandler-for-any-Event-by-code Possibly relevant. – CollinD Oct 01 '15 at 19:35
  • How and when is GetSub called? How are you getting the handle to pass to getsub? – John Oct 01 '15 at 20:05
  • I know this isn't what you're looking for but may help lead you in the right direction. You can get the name of the calling sub from doing a stack trace. Maybe you can get the handle as well. MsgBox((New System.Diagnostics.StackTrace).GetFrame(1).GetMethod.Name) – John Oct 01 '15 at 20:06
  • Why do you want to do this in the first place? It seems a very strange thing to do. It may be that there's a better option. – jmcilhinney Oct 01 '15 at 23:48
  • @jmcilhinney I want to my program generate a new button when needed that will have all the properties of the original even it's EVENTS. Can you help me find a better way? – AFT X-Star Oct 02 '15 at 21:21
  • Are you saying that you want to be able to duplicate any arbitrary `Button` or is this a specific set of `Button` controls that are always going to have the same `Click` event handler? – jmcilhinney Oct 03 '15 at 03:01
  • Exactly! But sometimes I will need to do the same with other controls, not only Buttons. Can you help? – AFT X-Star Oct 03 '15 at 13:27

0 Answers0