calling form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darin

    calling form

    I have a program that (for example), has form A that opens form B that
    opens form C, and form C calls a function, and that function calls a
    sub. From that last sub, i need to know if came specifically from form C
    (and not form A or B).

    Is that possible? If so, how? Some more information, form A is in my
    EXE, form B and C are in a DLL, and the function and sub are in
    different DLLs than the forms.

    Darin

    *** Sent via Developersdex http://www.developersdex.com ***
  • rowe_newsgroups

    #2
    Re: calling form

    On Jul 5, 6:09 pm, Darin <darin_nospam@n ospameverwrote:
    I have a program that (for example), has form A that opens form B that
    opens form C, and form C calls a function, and that function calls a
    sub. From that last sub, i need to know if came specifically from form C
    (and not form A or B).
    >
    Is that possible? If so, how? Some more information, form A is in my
    EXE, form B and C are in a DLL, and the function and sub are in
    different DLLs than the forms.
    >
    Darin
    >
    *** Sent via Developersdexht tp://www.developersd ex.com***
    Wow, reading that was really confusing. My first suggestion would be
    to find another way to do what you want to do. If it's difficult to
    explain when you post to the newsgroups, you can be it will be hard to
    explain to the maintenance programmer. And a confused maintenance
    programmer = wasted time and money.

    But if you absolutely need to know who called the method, you could
    follow the same approach used in the .NET events, pass in a "sender As
    Object" parameter. If you do that you could easily inspect what/who
    called the method.

    Thanks,

    Seth Rowe [MVP]

    Comment

    • Darin

      #3
      Re: calling form

      My example might have looked confusing, but it actaully isn't.

      I have an application that is started w/ an EXE. Within the EXE it opens
      a ut.dll that has a main menu in it. If the user selects customer file,
      the customer file is in an ar.dll. Now, i have MANY subs and functions
      in a standard libs.dll that can be called from anyplace in my program.

      THat is basically what i want - from a sub or function in my libs.dll, i
      want to knwo the form that called it.

      You suggestion was the one i had though of, i just didn't know if it
      was/is included in a trace or something, since when the sub/function
      exits it has to know where to go back to.

      Darin

      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Phill W.

        #4
        Re: calling form

        Darin wrote:
        I have a program that (for example), has form A that opens form B that
        opens form C, and form C calls a function, and that function calls a
        sub. From that last sub, i need to know if came specifically from form C
        (and not form A or B).
        Why should the Sub /care/ who called it?
        Each method should have a specific purpose and, as far as possible,
        should be able to "get on with it" without having to "go back" to its
        caller for anything.

        You have two choices:

        (1) Pass the calling Form [all the way] through to the Sub, then you can
        interrogate it there.

        Sub LastSub( ByVal callingForm as Form )
        If TypeOf callingForm is FormC Then
        ' Form 'C'-specific implementation
        . . .
        End If
        End Sub

        (2) Is the Sub /really/ a separate, library routine or is it a function
        of each Form and that behaves differently for each one?
        If so, Then you need to be thinking of adding that Sub /into/ each of
        the Forms, using either Inheritance or an Interface, whichever you prefer.

        Class FormA
        Public Overridable Sub LastSub()
        ' "default" implementation here
        End Sub
        End Class

        Class FormB
        Inherits FormA

        ' No override, so just uses the "default" implementation
        ' from FormA

        End Class

        Class FormC
        Inherits FormA

        Public Overrides Sub LastSub()
        ' 'C'-specific implementation here
        End Sub

        End Class

        HTH,
        Phill W.

        Comment

        Working...