|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
is there a way to do thishey 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 =?Utf-8?B?YXJp?= <a**@discussions.microsoft.com> wrote in
news:8B7129BF-F8EA-411D-8684-B873E756BC5D@microsoft.com: *Confessor nods*> 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 > > 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. You'll want to check the stack trace.
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20620588.html 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 thanks everyone for the great feedback.
Show quoteHide quote "ari" wrote: > 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 |
|||||||||||||||||||||||