Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

When I create a form in vb.net, vb automatically makes use of

 

Inherits System.Windows.Forms.Form

 

With this, I am unabvle to inherit other classes as it is already taken up by this. Is this necessary? Is there another way aroun this problem?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
  • *Experts*
Posted
If it doesnt inherit from form than the class will not be a form. You cant inherit from anything else if you want to have a form. Create another class and inherit from whatever you need.
Posted

i see, haih...then the purpose of inheritance in vb.net plays a very little role am i right? coz many things in vb are done thru the interface...

 

so my code on a form can't inherit a class? haih...

really no other way? if not i'll have to define the functions in a module...and call the functions that way, would that be better? in fact, is that similar to inheritance?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
  • *Experts*
Posted

Inheritance in .NET plays a huge role :) For example every control inherits from the base Control class.

If you put functions in a module you will not be able to inherit at all. If you want to inherit from something create another class. What are you trying to do? It will be easier to explain and get to what you need if I know what you are trying to do :)

Posted

hm.......

i mainly have many lines of code which are kind of similar, especially when i have many buttons on my form which, when clicked, connect to the database to carry out some operations...

 

i plan to centralise these lines of code, so that they can all be reused...

 

any ideas?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
  • *Experts*
Posted
You dont need inheritance for that, you just need some functions to accept parameters that you need. Those should easily be implemented in your form class. Database connections dont require any special inheritance.
Posted
i see, er........would it be less efficient to create a few more database connections than to just maintain and reuse a single connection variable?
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted

.NET does not support multiple inheritance. That's what you are experiencing.

 

Still you could could have a new class that inherits from system...form and implement some general methods in that "root" form, then let your other forms inherit from the root form.

 

Even better, split your application in 3 or more layers (tiers). One for the GUI handling and nothing more. One for the Data Access (and nothing more) and one for business rules. In the business rules layers, you need not inherit from system..form.

 

So.

:-)

.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...