+ Reply to Thread
Results 1 to 3 of 3

accessing members of a class object passed in as variant type?

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    58

    accessing members of a class object passed in as variant type?

    I have a subroutine which accepts variant user-defined type because I want to make it general enough for all my class objects. They all contain a particular member called dirtyflag so I would like to use this subroutine to process and access this member no matter what class object is passed inside.

    But VBA does not seem to like this kind of practice. During runtime it gives me error.

    So, I suppose VBA is not able to resolve type at runtime to access the member variable?

    So does it mean I have to create different subroutines catering to each class object, no matter how similar they all appear?
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 11-22-2013 at 03:00 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: accessing members of a class object passed in as variant type?

    Hello vientito,

    In VBA the object must be of the class that has dirtyflag as a property.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    58

    Re: accessing members of a class object passed in as variant type?

    I have found out the reason behind. I have declared this member as a friend and it seems that it won't work with late-binding object at all. Once I put public instead everything works

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Call members from an implemented class
    By baldphil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2012, 12:35 PM
  2. [SOLVED] is a variant an object
    By James Cornthwaite in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2006, 06:55 PM
  3. [SOLVED] Userform.Caption is blank when reference passed to class
    By NickHK in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2006, 11:30 AM
  4. how to redim the type of variant element
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-25-2005, 03:05 PM
  5. [SOLVED] Type mismatch accessing variant array too many times
    By peter in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2005, 07:06 PM

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