+ Reply to Thread
Results 1 to 4 of 4

Use of the "Me" Keyword

  1. #1
    Registered User
    Join Date
    04-21-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Use of the "Me" Keyword

    I am writing a macro which requires the placement of "Units" into "Cartons".

    I have a Carton class and a Unit class. The Carton class has a property Contents which is an array of Unit objects. The Unit class has a property MyCarton which is a Carton.

    The Unit class also has a method "placeIntoCarton" which takes a Carton object as an input and sets that to its MyCarton property.

    The Carton class has a method "Add" which takes a Unit object as an input and adds it as an element in the Contents array. I would like to call the "placeIntoCarton" method from within the "Add" method, so I can associated a Carton instance and an Object instance with eachother by calling just one method. In other words, if I look at the "Add" method inside the Carton class, I want to say

    Please Login or Register  to view this content.
    As of right now, this doesn't work, though I haven't tried everything yet.

    Is this appropriate usage of the "Me" keyword? What is the proper way of doing this?

    Thanks for all help. Really appreciated.
    Last edited by Farmer; 04-21-2011 at 12:06 PM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Use of the "Me" Keyword

    Hi,

    If I understand correctly:

    Carton Class
    Please Login or Register  to view this content.
    Unit class
    Please Login or Register  to view this content.
    Module1 Standard Code Module:
    Please Login or Register  to view this content.
    Note that when you pass an object (ie. an instance of a class) as an argument, if you surround it with brackets () then those brackets will cause the default member of the class to be called.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Registered User
    Join Date
    04-21-2011
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Use of the "Me" Keyword

    Thanks Colin.

    I believe the "()" was the bug. No matter how many times that happens I never seem to remember.

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Use of the "Me" Keyword

    No problem. I think the other 'concern' is that you're using the word Object as a variable name. An Object is a data type, so best to use something else. eg. objUnit or objCarton

+ 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