Determining the class that called the function

Posted on 2005-04-06
Last Modified: 2010-04-23

I have a function in a module and multiple classes. Is there any way to determine which class called the function within the function, without passing any variables.

Question by:adam_pedley
    1 Comment
    LVL 19

    Accepted Solution

    Hi Adam
    you can do that
    You need to check the StackTrace

    here goes...

            Dim strace As New StackTrace
            Dim frame As New StackFrame
            frame = strace.GetFrame(1)
            MsgBox("Calling Function" & frame.GetMethod().Name)

    Frame 0 gives the uppermost fn in the Trace which will be this fn itself, 1 gives the next fn, which will be the calling fn.
    so frame = strace.GetFrame(1)

    hope that's what you want

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now