+ Reply to Thread
Results 1 to 5 of 5

Return an Array from Class Property

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Crewe, England
    MS-Off Ver
    Excel 2007
    Posts
    37

    Return an Array from Class Property

    Hello All,
    I'm in the process of creating a Class (cCampaign) which contains various properties. I've done some simple ones without issue and tested successfully. However, I'm trying to create an additional property that will return an array of Row numbers (generated by searching for the cCampaign object name stored within a Collection Class (called cCampaigns). I've written the code below but it returns a 'Type Mismatch' error. I thought it should be simple to spot but can't see the error in my ways. I would greatly appreciate advice and/or solutions to this problem.
    As ever, your patience with my lack of experience is welcomed!

    Please Login or Register  to view this content.
    In the standard module, my intended code will be something like as follows:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Return an Array from Class Property

    At a glance, the signature should be

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Crewe, England
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Return an Array from Class Property

    Thanks for your reply, "shg" - I am now further with my project, but not much.

    I've now changed the class properties slightly so that I can return both the full array of row numbers and individual row numbers from the array. To accomplish this I've created a sub that creates the array and simplified the property procedures (and am hoping this is the way to do it). However, when I now run the code I get runtime 91 error (with block not set) at a point that didn't previously stick. I think the issue could be the method or location of the line that calls the sub but i can't be sure. The following extract is within the cCampaigns class that creates a 'cCampaign':

    Please Login or Register  to view this content.
    The assignRowNums code sits within the cCampaign class module and is as follows:

    Please Login or Register  to view this content.
    Any clues/solutions to why this doesn't work will be much appreciated.

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Return an Array from Class Property

    you declare a variable
    Please Login or Register  to view this content.
    but never initialize it before you try and use it
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Crewe, England
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Return an Array from Class Property

    Thanks JP. It's always the simple things I overlook! This is no longer a problem as I'm using the class slightly differently and no longer need to return the array in it's entirety (only access individual elements one at a time).
    Last edited by williams485; 09-07-2012 at 05:16 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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