473,785 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call child's function from parent form

LEE
I'd like to call a function of child from parent form,
there is an issue:

Form1 (parent) calls "LoadMe" Sub in Form2 (child), it
works using the codes (in Form1):
Dim frm As New Form3()
frm.LoadMe()

but fails using these codes:
Dim frm As Form ' defined as a global variable
frm = New Form3()
frm.LoadMe()

How to fix it?

Thanks
Nov 20 '05 #1
3 6265
"LEE" <an*******@disc ussions.microso ft.com> schrieb
I'd like to call a function of child from parent form,
there is an issue:

Form1 (parent) calls "LoadMe" Sub in Form2 (child), it
works using the codes (in Form1):
Dim frm As New Form3()
frm.LoadMe()

but fails using these codes:
Dim frm As Form ' defined as a global variable
frm = New Form3()
frm.LoadMe()

How to fix it?


Dim frm As Form3 ' defined as a global variable
frm = New Form3()
frm.LoadMe()

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
"LEE" <an*******@disc ussions.microso ft.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
I'd like to call a function of child from parent form, .. . . Dim frm As New Form3()
frm.LoadMe()

but fails using these codes:
Dim frm As Form ' defined as a global variable
frm = New Form3()
frm.LoadMe()
Fails /how/ exactly? Exception message?
We're not [all] psychic... ;-)

If you're using Option Strict (and you should be), you might need
to type-cast Form3 into your Form variable.

Assuming that Form3 is a Windows.Forms.F orm (and you're not
using Option Strict, which you should be), I would still question this
line:
Dim frm As Form ' defined as a global variable


(OK, code and comments frequently disagree, but... )
In VB.Net, this syntax can /never/ give you a Global variable.
In a VB6 module, yes, Dim is the same as Public or Global, but here,
in the Brave New World, this is the same as coding:

Private frm As Form

which will /only/ be accessible within the Module.

You /are/ using "Option Explicit On", aren't you?

HTH,
Phill W.
Nov 20 '05 #3

"LEE" <an*******@disc ussions.microso ft.com> wrote in message
news:0a******** *************** *****@phx.gbl.. .
I'd like to call a function of child from parent form,
there is an issue:

Form1 (parent) calls "LoadMe" Sub in Form2 (child), it
works using the codes (in Form1):
Dim frm As New Form3()
frm.LoadMe()

but fails using these codes:
Dim frm As Form ' defined as a global variable
frm = New Form3()
frm.LoadMe()

instead of calling frm.loadme you would have to do

Ctype(frm, form3).Loadme

frm itself has no method named Loadme, so does not really know that load me
exists.
How to fix it?

Thanks

Nov 20 '05 #4

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

Similar topics

13
7411
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
2
10207
by: PawelR | last post by:
Hello Group, In my application I have few class, and I want call function with "master class". This is as master form (startClass) and option window (ClassA). My question is how call function from startClass in classA? public startClass : System.Windows.Forms.Form { static void Main() {...}
1
1961
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is engaged. When the owner closes one of his child windows, I want to update the master window. I understand "reasonably" well how to go about this. The master window launches the children, and maintains an associative array to keep track of each one....
2
2167
by: SHAWN DEB ECKLEY | last post by:
Here is my situation... i have a parent window/ main app and i call a child form (type 1). the child form(type 1) gets information from a database. the user makes some choices and then some data is sent to the next child form(type2). i am having problems making this work. I have tried instantiating the second child form right after the first from the parent window. this brings up both at the same time. i have put the code for...
5
8042
by: midnight_use_only | last post by:
hi all, quick question, how do you submit a form to a parent window from a child popup window? i have the following and all online documentation *suggests* that it should work but it does NOT: // Parent window: <script language="JavaScript"> function popup(url, name) { window.open(url, name, "width=800,height=600,scrollbars=yes");
7
5824
by: Sheikko | last post by:
Hi all, i have an application and i wan to call another program into it, like notepad, so when i minimize the notepad, or maximize, it must rest in my application. thank you
29
3910
Frinavale
by: Frinavale | last post by:
I have 2 FireFox (version 2) browser windows opened. One is the child of the other. When the user is finished with the child window, a method in the parent window is called to refresh a section of the page. This is the JavaScript code that I'm using to refresh the content in the parent page: <script type="text/javascript"> function UpdateList() {
1
6473
by: Beamor | last post by:
function art_menu_xml_parcer($content, $showSubMenus) { $doc = new DOMDocument(); $doc->loadXML($content);//this is the line in question $parent = $doc->documentElement; $elements = $parent->childNodes; need help. my site worked fine on my localhost but when i uploaded it to my live server i keep getting this error need help to recode line to match my hosting server. im using php 5 i have attached the common_method file
0
9645
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10336
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9953
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
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.