473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 ***
Jul 5 '08 #1
3 1124
On Jul 5, 6:09*pm, Darin <darin_nospam@nospameverwrote:
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 Developersdexhttp://www.developersdex.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]
Jul 6 '08 #2
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 ***
Jul 6 '08 #3
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.
Jul 7 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: headware | last post by:
I know that you can call the method of one from from inside another form by doing something like this Forms("MyForm").MyFunction(12, 34) However, you have to know that MyForm has a function...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
2
by: mark | last post by:
I am developing an application in .Net C# that needs to restore a number of tool windows to some previous location and size. The problem I have is that when I create the form and set the Location...
2
by: Renzo | last post by:
hi ! i've recently begun developing in c# and i'd like to know what's the best way of calling a form from an already instanced form ? I have done a "Login" form which I run in the Main() using...
6
by: Amjad | last post by:
Hi, I want to make a project that calls and executes a function (VB code) made in a seperate file in the Application Folder. I know I can create the function in my project and call it internally,...
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
1
by: SAL | last post by:
Hello, I'm developing this remoting app (.net 2.0) and I need to bring the server app's form to the front often. Since you can not do cross-thread communication on a form or control without using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.