+ Reply to Thread
Results 1 to 10 of 10

why to set up public property

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    why to set up public property

    Hi,

    what is a purpose of setting up public property?

    like :

    Please Login or Register  to view this content.
    Where should i put this? In class module?

    What this class name should be?

    Best,
    Jacek

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: why to set up public property

    Generally yes you would put a property in a class. It really doesn't matter what you call it (though it's best to avoid VBA or Excel keywords)
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438

    Re: why to set up public property

    Couple of reasons,

    creation of read/write, readonly and writeonly properties.
    execution of additional code when reading and or writing properties.

    Module
    Please Login or Register  to view this content.
    Class Class1
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: why to set up public property

    thank you very much Andy and Rory!

    Great explanation.
    Jacek

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: why to set up public property

    Andy,

    i am getting error in your code. Is should be:

    Please Login or Register  to view this content.
    And i have another error like here:

    Screenshot_4.png

    can you please help with this?
    Jacek
    Last edited by jaryszek; 04-11-2019 at 04:04 AM.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: why to set up public property

    Andy's code was (as expected) correct as written - make sure you read the comments!

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: why to set up public property

    thank you.

    So what is a purpose to get error here?

    Jacek

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: why to set up public property

    It was to demonstrate read-only and write only properties.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: why to set up public property

    aaa ok. Understand .

    thank you!

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438

    Re: why to set up public property

    Here is the code in a workbook.
    The 2 compile lines are commented out.

    I don't get the error you report so you must have added extra code.
    Attached Files Attached Files

+ 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] Can't Assign to Read-Only Property; Compile Error on Assigning Property to Class.
    By Dal123 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-15-2018, 08:09 AM
  2. [SOLVED] code for listbox give could not set the list property . invalid property value
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2017, 10:22 AM
  3. Classes - Public Property Set Confusion!
    By reyreyreyes in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-22-2016, 08:24 PM
  4. Public Property Get + Variable Counting - Curiosity!
    By reyreyreyes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2016, 12:01 PM
  5. Runtime error 381: Could not set the list property.Invalid property array index
    By rohith4prithvi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2014, 10:24 PM
  6. [SOLVED] Excel run-time error '381': Could not set the List property. Invalid property array index
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-20-2012, 12:48 PM
  7. Understanding Cells property vs. Offset property (implicit vs explicit references)
    By Wedge120 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-26-2010, 10:38 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