Home All Groups Group Topic Archive Search About

is there a way to do this

Author
14 Feb 2006 4:20 AM
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

Author
14 Feb 2006 4:46 AM
The Confessor
=?Utf-8?B?YXJp?= <a**@discussions.microsoft.com> wrote in
news:8B7129BF-F8EA-411D-8684-B873E756BC5D@microsoft.com:

> 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.
Author
14 Feb 2006 5:05 AM
jonathan.roes@gmail.com
Author
14 Feb 2006 5:00 AM
CMM
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

--
-C. Moya
www.cmoya.com
Author
14 Feb 2006 7:53 AM
YaroslavKo
You can use "System.Reflection.MethodBase.GetCurrentMethod.Name"  to
know the methods and functions names in runtime
Author
24 Feb 2006 10:13 PM
ari
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