+ Reply to Thread
Results 1 to 2 of 2

Lost in Set, Get, Let, Sub, and Function at an Intermediate Level of Knowledge/Practice

  1. #1
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Lost in Set, Get, Let, Sub, and Function at an Intermediate Level of Knowledge/Practice

    *Beginner level of knowledge
    I am using several classes in my projects and I want to make sure I'm using the subject methods (?if that's the correct term?) correctly. Any clarification to what I understand below is helpful

    I want to make sure I'm following good coding practices. I've been using lengthy Subs, Functions, Lets, and Gets within Class Modules that may amount to more than 2,000 lines of code/class module. Most functions and subs I create are private, but I've used some public functions that return values just like the Get property.

    QUESTION: Why would I create a Get in a Class instead of Function in a class (or vice versa) if both a function and a Property Get can manipulate and return a class's private variable?
    That question then leads me to ask:
    QUESTION: Why would I use a Let in a class instead of Sub in a class (or vice versa) if both a sub and a property can manipulate a class's private variable based on its input?
    ...isn't a sub() more functional/useful than a Let b/c you can pass multiple inputs into the class to manipulate a private variable?

    My understanding:
    Sub: used when no output is required (cannot output any values)
    Function: Used when an output is required... but that is also the case with a Get method
    Get: used to return (and manipulate) private variables, potentially based on an input... seems a function is more useful than a Get
    Let: used to set (and manipulate) private variables (no input available except what you pass to it)... seems a cMyClass.(sub Name) is more useful than a cMyClass.(Let Property Name)

    I've been writing some nontrivial Properties that go far beyond a simple: Variable = pVariable lines of code (where pVariable is a private Variable of the same datatype as Variable)

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

    Re: Lost in Set, Get, Let, Sub, and Function at an Intermediate Level of Knowledge/Practic

    Properties are single data points, such as size or color or value. The use of GET/LET/SET allows for readwrite, readonly and writeonly.
    You can then use code like this for a class that has a get/let property called color.

    Please Login or Register  to view this content.
    Methods are sub and functions. These can have multiple input arguments and as you say function can return a single result.

    You can not use the same name for a sub and function.
    Cheers
    Andy
    www.andypope.info

+ 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] Intermediate level VBA questions that should be super simple to answer if you already know
    By zzzjoshzzz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2014, 06:53 PM
  2. Hi! Intermediate level Excel user here...
    By FaithH in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-14-2014, 09:16 PM
  3. Replies: 2
    Last Post: 03-10-2013, 09:56 PM
  4. Identify top 3, bottom 3 and intermediate values using IF function
    By nataliebenjamin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-17-2012, 03:28 PM
  5. Creating a schedule - intermediate level user
    By jamicam in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-25-2012, 10:48 AM
  6. Excel tutorials/books for Intermediate level
    By Semusal in forum The Water Cooler
    Replies: 0
    Last Post: 07-05-2012, 02:55 AM
  7. Replies: 4
    Last Post: 01-31-2005, 10: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