Link to home
Start Free TrialLog in
Avatar of Sheritlw
SheritlwFlag for United States of America

asked on

Using MyBase, MyClass?

Hi EE,

I am very new to .net and have created a class that handles all inserts, updates, deletes, etc. for all my lookup tables.
I have enumerated all my tables and defined how many fields they have and the types of fields and then by sending in the table name it creates the insert, update etc. for me.
This class inherits my Basic connection class.
All of this is working.
I am now building a class that will build grids according to what I have specified in my lookup class.  i.e number of columns, field type etc.
I have inherited the lookup class in this new class, but it keeps saying that I need a sub new and it needs to start with mybase or myclass.
The lookup class has a sub new that brings in the connection string and tablename but this class doesn't need a connection to the db.
What is the mybase and myclass and how do I use it?
Thanks
Avatar of freer
freer

> The lookup class has a sub new that brings in the connection string and tablename but this class
> doesn't need a connection to the db

This suggests that you don't want to inherit from the lookup class.

MyBase is a way to call the methods of the base class (from which you inherit) in the sub class (your new class).

MyClass is a way to call the methods of the current class in a way that cannot be overridden.

Tim
See here for the official explanation:

http://msdn.microsoft.com/en-us/library/c8shwxa5(vs.71).aspx

The reason I'm suggesting inheritance is inappropriate here is that normally you inherit because you want a more specialized version of the same thing. Eg. you might have a class Person and inherit from it in the class Employee. However if your new class doesn't need a connection, it sounds like it is a different thing completely, not a more specialized version of the same thing.

Tim
Avatar of Sheritlw

ASKER

That makes since.
If I take out inheritance, how can I easily use all the properties/functions etc. in the lookup class?
Thanks
You can either have a reference to an instance of the lookup class and call its members. Or you can make the methods of the lookup class shared in which case you can call them without an object instance.

Tim
I changed one of the functions to shared which has a select case for the table names.  It says I cannot refer to an instance member of a class with a shared method etc.
How do I handle that?
Thanks,
ASKER CERTIFIED SOLUTION
Avatar of freer
freer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, I agree.  I have been reading and reading for weeks now and still struggling.  It's so different than VB 6, but I will learn.
Thanks for the info... it was good.