+ Reply to Thread
Results 1 to 3 of 3

Class and one property is also a class or collection

  1. #1
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Smile Class and one property is also a class or collection

    Hi,

    I have the following data that I put in an array.

    ID---------Name-----Type---------NR--------De---------Cr
    A001----Chris-------F66----------1111-----------------10
    A001 ----Chris-------FACT-------1234------10
    A001 ----Chris-------F66----------5678-----15
    B002 ----Sarah------F58----------2222-------7
    C003 ----Bill----------FACT--------3333-------5
    To put it in an array I used this.

    Please Login or Register  to view this content.
    Now I'm trying to put everyting in classes.

    The Class is called clsClient
    And has the following properties:

    Please Login or Register  to view this content.

    But I'm stuck with the invoice properties cause I should use a different class.
    For example clsInvoice with the following properties:

    Please Login or Register  to view this content.

    1) How can I add the clsInvoice as a property to clsClient cause it's not one invoice per client but there can be several invoices.
    Do I need to create another class to hold all the invoices? Like a collection class?
    (I have no experience with collection classes)

    2) How can I loop through the array and fill the class correctly.
    This code is not finished and definitely wrong :-/

    Thanks in advance!

    Greets
    Last edited by gosa; 12-01-2011 at 05:32 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Class and one property is also a class or collection

    The simplest way would be to add a Collection object to the first class and then add the invoices to that.
    I would also recommend reading through Patrick's article here.
    Last edited by romperstomper; 12-01-2011 at 06:15 AM.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    04-07-2011
    Location
    Gent, Belgium
    MS-Off Ver
    Excel 2007
    Posts
    38

    Smile Re: Class and one property is also a class or collection

    Quote Originally Posted by romperstomper View Post
    The simplest way would be to add a Collection object to the first class and then add the invoices to that.
    I would also recommend reading through Patrick's article here.
    Hi thanks for the link.
    After reading the other links in the article and experimenting I was able to solve it.
    I did it manually though without the add-in because for some very strange reason I was only able to use the add-in once. After I filled the form in and closed Excel and went back in to try the add-in again. I always got a error 94, something about 'Invalid use of Null'.

    Anyway it worked so I'm glad.

    As for my project I ended up with 4 classes.
    2 basic classes and 2 collection classes.

    Thanks again for getting me on the right track.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1