[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

additional properties and methods to existing class

Hello All,
               I have a set of Excel workbooks with similar features which I think would be nicely dealt with thru classes. I would like to add some properties and methods but how I can add them if this object class, workbook, already exists with its standard set of properties, methods, and events?

Thank you very much!
0
Autofreak
Asked:
Autofreak
  • 4
  • 4
1 Solution
 
Arthur_WoodCommented:
Are you asking about this in VB 6, or .NET?

AW
0
 
AutofreakAuthor Commented:
It's VB6. Thanks
0
 
Arthur_WoodCommented:
The only way to accomplish this would be to create your own class , and in that class create an object of the original class.  In the new class you would re-create ALL of the properties and methods of the old class that you wanted to 'mimic', and in the properties and  methods, you would 'delegate' to the internall object of the old class.  You would then add any new properties and methods to your class, to extend the functions.

This is called inheritance by DELEGATION.  

VB.NET would allow you to use FULL, complete Object-Oriented Inheritance, and would be much more straightforward.

AW
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AutofreakAuthor Commented:
Excellent Arthur, that is the path I thought of taking too.

Thanks,
Serge
0
 
Arthur_WoodCommented:
so why only a B???

AW
0
 
AutofreakAuthor Commented:
Hey Arthur,
                 sorry if my mark caused your disagreement  - I respect your point of view. I gave "B" because to me an A answer would have to have an example of such "mimmicing" the way it would be done in VB6. If you insist I can raise this issued again and with pleasure award you an A. Say, we need a class clsCashRec that have all properties of an Excell workbook and for which we implement a method Reconcile. This method would look like myWorkbook.Reconcile

I'd appreciate if you could show how to do that and even raise the pints awarded to 250.

Thanks!
 
0
 
Arthur_WoodCommented:
no, but you could have asked for the additional explanation.

Public Class clsCashRec
    Private m_clsCashRecXLS as Excel.WorkBook
    Private m_LocalData as Integer

    Public Sub Class_Initialize()
       Set m_clsCashRecXLS  = New Excel.WorkBook
    End Sub

    Public Property Get WorkBookPropertyToMimic1() as PropertyType
         WorkBookPropertyToMimic1 = m_clsCashRecXLS.WorkBookPropertyToMimic1
    End Property
    Public Property Let WorkBookPropertyToMimic1(RHS as PropertyType)
         m_clsCashRecXLS.WorkBookPropertyToMimic1 = RHS
    End Sub
.
.
.
    Public Sub Reconcile(ByVal Arg as ArgType)
     '  code to do what you need to do, using the m_clsCashRecXLS  workbook object as needed
    End Sub
End Class

is the basic structure of the approach, using DELEGATION

AW
 
0
 
AutofreakAuthor Commented:
Thanks a lot Arthur!,
                       You now what, I lost my confidence temporarily since one of the experts slept me a worning that asking additional questions, and in that case the situation was very close, is violating the clause about asking several questions in one Q.   I desagreed with him in writing  , (http://www.experts-exchange.com/Databases/MS_Access/Q_21373500.html) but decided to act more concervatively. This case proves my point - additional answares MUST be asked for the answer to rich its maximum value!!!

Do you want you me to post this Q once again?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now