Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 13th, 2004, 11:37 PM
Registered User
 
Join Date: Apr 2004
Location: Clarence Center, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default base class inheritance

When I am using inheritance can I:
1.) use more than 1 base class

2.) when using the properties in the derived class can the variables be shared between 2 derived classes and 1 base class.

If anyone can show or thoroughly explain how these 2 situations can be done, it would make me understanding of vb.net object instantion a lot more clearer. I would really love a sample of a project with 2 derived classes using the same base class so I see how they are referenced between one another.

I bet this idea would really help alot of us beginners and intermediate developers the correct way to use inheritance.

Sincerely,

Ferd Krantz

F. Krantz
Reply With Quote
  #2 (permalink)  
Old April 14th, 2004, 08:17 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

1. No. VB.NET supports only single inheritance

2. Not directly. Remember, the inherited class becomes part of the derived class. The instance of that class doesn't care that some of it is inherited. As with any two instances of any two objects- they talk through properties and methods. They can't share data directly. Like set a property in one and the other just changes. You would need to store the data outside of the object - like in a database or a session variable- for the data to be exchanged. You could also have the changed object call the other one and change the properties. But it's not something that just "happens".


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #3 (permalink)  
Old April 15th, 2004, 08:54 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Fred,

You actually can do this. It involves using class scope variables. Although this is really not a common practice it can be handy when you need to have a variable that should be applied to all instances of a class (or sub class). Take a look at this article for a more comprehensive explanation and some examples:
http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=272

Peter
-------------------------
Work smarter, not harder
Reply With Quote
  #4 (permalink)  
Old April 15th, 2004, 09:14 AM
Friend of Wrox
Points: 3,489, Level: 24
Points: 3,489, Level: 24 Points: 3,489, Level: 24 Points: 3,489, Level: 24
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Central, NJ, USA.
Posts: 1,102
Thanks: 0
Thanked 2 Times in 2 Posts
Default

See, I should stop answering technical questions :)

Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
Reply With Quote
  #5 (permalink)  
Old April 16th, 2004, 09:41 AM
Registered User
 
Join Date: Apr 2004
Location: Clarence Center, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 Fred,

You actually can do this. It involves using class scope variables. Although this is really not a common practice it can be handy when you need to have a variable that should be applied to all instances of a class (or sub class). Take a look at this article for a more comprehensive explanation and some examples:
http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=272

Peter
-------------------------
Work smarter, not harder
F. Krantz
Reply With Quote
  #6 (permalink)  
Old April 16th, 2004, 09:56 AM
Registered User
 
Join Date: Apr 2004
Location: Clarence Center, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I made a mistake and pressed the post button before responding, oops.

I just want to thank you for the help and would like to ask you if you have a simple shell of a multiple inheritance with a class and a inheritance with multiple forms that inherit.

I am studying the book Programming in VB.NET by Julia Bradley in a beginning VB.NET course.

I really like the idea of inheritance, unfortunately most books do not give complete information or don't show examples thoroughly so it is completely understood so there is no doubt in how to use it properly in future projects I design.

It is sad to see so many books with incomplete examples and poorly explained details needed to properly design OOP VB.net projects.

Keep up the fine forum,
Fred

Quote:
quote:Originally posted by planoie
 Fred,

You actually can do this. It involves using class scope variables. Although this is really not a common practice it can be handy when you need to have a variable that should be applied to all instances of a class (or sub class). Take a look at this article for a more comprehensive explanation and some examples:
http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=272

Peter
-------------------------
Work smarter, not harder
F. Krantz
Reply With Quote
  #7 (permalink)  
Old April 23rd, 2004, 11:48 AM
Registered User
 
Join Date: Apr 2004
Location: Clarence Center, NY, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured out the solution to inheriting a form when using a base form. It is straight forward just remember to include at the top of the form the following.

import [form path]

class derived form
       inherits base form

That is it for inheriting another form as a base form, now use all the known key words for overriding the functions and sub's.

I thank everyone who has added to this forum, it was helpful to actually have a place to search for answers and experiment and get an answer I can actually understand and code easily.



Quote:
quote:Originally posted by krunch97
 When I am using inheritance can I:
1.) use more than 1 base class

2.) when using the properties in the derived class can the variables be shared between 2 derived classes and 1 base class.

If anyone can show or thoroughly explain how these 2 situations can be done, it would make me understanding of vb.net object instantion a lot more clearer. I would really love a sample of a project with 2 derived classes using the same base class so I see how they are referenced between one another.

I bet this idea would really help alot of us beginners and intermediate developers the correct way to use inheritance.

Sincerely,

Ferd Krantz

F. Krantz
F. Krantz
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Behavior of "this" & "base" in inheritance guntank C# 7 September 27th, 2006 09:00 PM
Object Class and Multiple inheritance deepthraj BOOK: Professional C#, 2nd and 3rd Editions 1 May 23rd, 2006 12:57 PM
object class and multiple inheritance deepthraj General .NET 5 August 13th, 2005 10:12 AM
Question about Class Inheritance forkhead Pro VB.NET 2002/2003 0 March 21st, 2005 03:37 PM
Newbie question on the 2nd ed: Class inheritance elde BOOK: Professional C#, 2nd and 3rd Editions 0 December 9th, 2004 03:00 AM



All times are GMT -4. The time now is 03:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.