473,382 Members | 1,357 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,382 software developers and data experts.

Inheritance Question in VB.NET

Hi
I am new to VB.NET and I am trying to figure out how to exchange data
between 2 forms based on parent-child relationship between 2 forms. Form2 is
child of form1. In form1.vb, I am doing
Dim t As New Form2
t.Show()

This is really strange to me because by OOPS, a base class has no knowledge
of the child class and should be able to instantiate a child class object.

Can someone explain this? Also, can someone suggest a better way to exchange
data between 2 forms.

Regards

Saumitra
Nov 21 '05 #1
3 1201
Dim t As New Form2
t.mdiparent = me
t.Show()

Saumitra wrote:
Hi
I am new to VB.NET and I am trying to figure out how to exchange data
between 2 forms based on parent-child relationship between 2 forms. Form2 is
child of form1. In form1.vb, I am doing
Dim t As New Form2
t.Show()

This is really strange to me because by OOPS, a base class has no knowledge
of the child class and should be able to instantiate a child class object.

Can someone explain this? Also, can someone suggest a better way to exchange
data between 2 forms.

Regards

Saumitra


Nov 21 '05 #2
Ahhh, what you are talking about "parent<-->child" relationship between
forms is not the same as inheritance. In OOP, inheritence refers to the
fact that the methods, properties and member variables of a class are
"inherited" by the new class at compile time, whereas the Window Parent <->
Child relationship purely refers to the fact that one recieves messages from
the other. Your Form1 will contain a reference to your Form2 and your Form2
will contain a reference (parent) to your Form1. Both of the classes you
are using are derived from Windows.Forms, not from each other.

"Saumitra" <Sa******@discussions.microsoft.com> wrote in message
news:14**********************************@microsof t.com...
Hi
I am new to VB.NET and I am trying to figure out how to exchange data
between 2 forms based on parent-child relationship between 2 forms. Form2
is
child of form1. In form1.vb, I am doing
Dim t As New Form2
t.Show()

This is really strange to me because by OOPS, a base class has no
knowledge
of the child class and should be able to instantiate a child class object.

Can someone explain this? Also, can someone suggest a better way to
exchange
data between 2 forms.

Regards

Saumitra

Nov 21 '05 #3
"Saumitra" <Sa******@discussions.microsoft.com> schrieb:
I am new to VB.NET and I am trying to figure out how to exchange data
between 2 forms based on parent-child relationship between 2 forms. Form2
is
child of form1. In form1.vb, I am doing
Dim t As New Form2
t.Show()

This is really strange to me because by OOPS, a base class has no
knowledge
of the child class and should be able to instantiate a child class object.


Inheritance <> Parent <-> child relationship!

What you need is a reference to your instance of the form you want to
manipulate. There are different ways to make this reference available, for
example, by passing it in method parameters or assigning it to properties,
or implementing the Singleton design pattern if there can be only one
instance of a form:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

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

Nov 21 '05 #4

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Graham Banks | last post by:
Does using multiple inheritance introduce any more performance overhead than single inheritance?
4
by: JKop | last post by:
I'm starting to think that whenever you derive one class from another, that you should use virtual inheritance *all* the time, unless you have an explicit reason not to. I'm even thinking that...
5
by: Morgan Cheng | last post by:
It seems no pattern defined by GoF takes advantage of multiple inheritance. I am wondering if there is a situation where multiple inheritance is a necessary solution. When coding in C++, should...
10
by: davidrubin | last post by:
Structural inheritance (inheriting implementation) is equivalent to composition in that a particular method must either call 'Base::foo' or invoke 'base.foo'. Apparantly, The Literature tells us to...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
45
by: Ben Blank | last post by:
I'm writing a family of classes which all inherit most of their methods and code (including constructors) from a single base class. When attempting to instance one of the derived classes using...
60
by: Shawnk | last post by:
Some Sr. colleges and I have had an on going discussion relative to when and if C# will ever support 'true' multiple inheritance. Relevant to this, I wanted to query the C# community (the...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.