Web Development

General discussion


Inheritance in Visual Basic 6.0

By fredo1703 ·
I know that Visual Basic 6.0 strickly speaking does not support inheritance, but as I understand there are work arounds. I have not been to find any of them.

Can someone please tell me how to design my classes that support inheritance? The classes I am designing are being used to connect to a database in MS Access.

Thanks a million.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Implementation no, Interface, yes

by privately_owed In reply to Inheritance in Visual Bas ...

You're right, strictly speaking, VB6 doesn't support inheritance, in that an object can't inherit the implementation of another object (that is how the first object does it's work). What VB6 objects can do is inherit interfaces, which are groups of method signatures. This article has a little bit of info on how that works from a standpoint of version control.


You can also "fake" inheritance through composition: create a privateinstance of the object you wish to inherit from and duplicate its interface. The new object won't be type-compatible with the old one, but it's a start. This article creates a custom collection object by hiding a Collection inside a VB6 class:


Hope that helps you.

Collapse -

Almost forgot

by privately_owed In reply to Inheritance in Visual Bas ...

Seems like I read about a hardcore approach that a couple years ago in VBPJ, a "black belt" column my Matt Curland I think, that used some custom assembler code he cooked up that allowed some kind of implementation inheritance. It was messy as heck and way too much trouble for me, but if you are serious you can probably find something about it over on DevX.com.

Also - and I'm going to beat our resident Delphi evangelist to the punch here - You could always build your data access components in another language that supports inheritance, Delphi for instance, and wrap them as COM components so you can use them from VB.

Related Discussions

Related Forums