is there a way to do this

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,

Given a simple subroutine/function is there a way to find out who the caller
is? (what line of code called it)

thanks,
ari
 
hey all,

Given a simple subroutine/function is there a way to find out who the
caller is? (what line of code called it)

thanks,
ari

*Confessor nods*

Simply define it with arguments... the little things you find in the
parentheses of the "event" subs the development environment makes for you.

You'll want to ByVal or ByRef (See which one works; I often forget the
difference between the two) a variable as a string...

And whenever you call the sub, put between the parentheses some identifying
value, like "From Sub Main."

Or at least, that's how I recall doing it; it's been a few months since my
last project that required it.
 
Dim trace As New System.Diagnostics.StackTrace

If trace.FrameCount > 1 Then
Dim frame As System.Diagnostics.StackFrame = trace.GetFrame(1)

MsgBox(frame.GetMethod().Name)
End If
 
You can use "System.Reflection.MethodBase.GetCurrentMethod.Name" to
know the methods and functions names in runtime
 
Back
Top