473,585 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling a function in another form

Hi

Could somebody give me an example of a way to call another member function
of another form from a form that has been called using ShowDialog?

Thanks

Geoff
Nov 21 '05 #1
7 6000
"Geoff Jones" <no********@ema il.com> schrieb:
Could somebody give me an example of a way to call another member function
of another form from a form that has been called using ShowDialog?


Pass a reference to the form to your dialog before calling its 'ShowDialog'
method, for example, by assigning it to a property of the dialog.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Thanks for the prompt reply Herfried.

Could you give an example of this technique?

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uI******** ******@TK2MSFTN GP09.phx.gbl...
"Geoff Jones" <no********@ema il.com> schrieb:
Could somebody give me an example of a way to call another member
function of another form from a form that has been called using
ShowDialog?


Pass a reference to the form to your dialog before calling its
'ShowDialog' method, for example, by assigning it to a property of the
dialog.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
"Geoff Jones" <no********@ema il.com> schrieb:
Could you give an example of this technique?


In your dialog form:

\\\
Private m_ResultForm As MainForm

Public Property ResultForm() As MainForm
Get
Return m_ResultForm
End Get
Set(ByVal Value As MainForm)
m_ResultForm = Value
End Set
End Property
..
..
..
Me.ResultForm.L abel1.Text = "Hello World!"
///

In the main form:

\\\
Dim f As New DialogForm()
f.ResultForm = Me
f.ShowDialog()
f.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
As Mr Burns from the Simpsons would say...."Excelle nt"!!!

Thanks a lot Herfried

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"Geoff Jones" <no********@ema il.com> schrieb:
Could you give an example of this technique?


In your dialog form:

\\\
Private m_ResultForm As MainForm

Public Property ResultForm() As MainForm
Get
Return m_ResultForm
End Get
Set(ByVal Value As MainForm)
m_ResultForm = Value
End Set
End Property
.
.
.
Me.ResultForm.L abel1.Text = "Hello World!"
///

In the main form:

\\\
Dim f As New DialogForm()
f.ResultForm = Me
f.ShowDialog()
f.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
Just as a matter of interest though, why doesn't this work:

'from within the dialog code
Me.Parent.funti onInCallingForm ()

where funtionInCallin gForm() is the function in the form where the dialog is
created. That is, as the parent of the dialog is that form, I thought this
might work - it doesn't :(

Can anybody explain why it doesn't work?

Geoff

"Geoff Jones" <no********@ema il.com> wrote in message
news:41******** *************** @news.dial.pipe x.com...
As Mr Burns from the Simpsons would say...."Excelle nt"!!!

Thanks a lot Herfried

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
"Geoff Jones" <no********@ema il.com> schrieb:
Could you give an example of this technique?


In your dialog form:

\\\
Private m_ResultForm As MainForm

Public Property ResultForm() As MainForm
Get
Return m_ResultForm
End Get
Set(ByVal Value As MainForm)
m_ResultForm = Value
End Set
End Property
.
.
.
Me.ResultForm.L abel1.Text = "Hello World!"
///

In the main form:

\\\
Dim f As New DialogForm()
f.ResultForm = Me
f.ShowDialog()
f.Dispose()
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Nov 21 '05 #6
"Geoff Jones" <no********@ema il.com> schrieb:
Just as a matter of interest though, why doesn't this work:

'from within the dialog code
Me.Parent.funti onInCallingForm ()


There is no parent-child relation between the form that shows the form and
the form that is shown modally.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7
Interesting. Thanks again Herfried.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:O$******** ******@TK2MSFTN GP12.phx.gbl...
"Geoff Jones" <no********@ema il.com> schrieb:
Just as a matter of interest though, why doesn't this work:

'from within the dialog code
Me.Parent.funti onInCallingForm ()


There is no parent-child relation between the form that shows the form and
the form that is shown modally.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8

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

Similar topics

2
2390
by: Satish Chimakurthi | last post by:
Hi all, My question is surely a basic one, but somehow, I am not able to figure it out. I have a python file "satish.py" as follows: *satish.py* def main(): y()
10
600
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 called MyFunction. Can you specify a string for the function name like you can with the form name? That is can I do something like ...
14
2988
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() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
6
17556
by: Jon Hyland | last post by:
Ok, I'm a little rusty on this, it should be a simple problem but I can't figure it out. How can I handle form events in my main code page?? I'm creating a Windows App in C#. Rather than make my main form the startup object, I'd rather put my Main() function in a class or code file. Why? Because thats what I always do in standard C++ or...
5
4632
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
4
2239
by: Bugs | last post by:
Hi, I wonder if anyone can help me out. I'm building a vb.net application that has a form with a panel that contains several other sub forms (as a collection of controls). What I'm wanting to do is call a generically named public sub in the top-most sub form in the panel. I have the name of the top-most form as a string (eg. g_TopForm =...
13
18673
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
1
1742
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 Invoke, I declared a delegate to handle the cross-thread call to bring the form forward. Here's my code: Delegate Sub BringMeFront() Public...
10
6948
by: SQACPP | last post by:
Hi, I try to figure out how to use Callback procedure in a C++ form project The following code *work* perfectly on a console project #include "Windows.h" BOOL CALLBACK MyEnumWindowsProc(HWND hwnd, LPARAM lparam) {
0
7908
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.