fkheng Posted June 14, 2003 Posted June 14, 2003 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? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 14, 2003 *Experts* Posted June 14, 2003 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. Quote
fkheng Posted June 14, 2003 Author Posted June 14, 2003 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? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 14, 2003 *Experts* Posted June 14, 2003 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 :) Quote
fkheng Posted June 14, 2003 Author Posted June 14, 2003 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? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
*Experts* mutant Posted June 14, 2003 *Experts* Posted June 14, 2003 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. Quote
fkheng Posted June 14, 2003 Author Posted June 14, 2003 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? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Heiko Posted June 16, 2003 Posted June 16, 2003 .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. :-) Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.