title: VBA Custom Property Conundrum
body: <p>There is a question on VBA that i have asked persistently on Stack. I am willing to go into great pains and lengths to find the answer. Be aware it may look silly and childish but it's a tricky snide question and almost everyone misses the answer consistenly.</p>
  
  <hr>
  
  <p>According to my books on VBA (Bill Jelin - VBA Macros Microsoft Excel 2010) when we are creating a custom object we open a class module. <strong>The properties of the custom objects are variables declared Private or Public.</strong> <strong><em>This seems extremely  illogical for me!!! I will illustrate in the picture below why.</em></strong>
  <img src="https://i.stack.imgur.com/TJAuu.png" alt="enter image description here"></p>
  
  <ol>
  <li>Simply it's Range("A1:A4")</li>
  <li><p>A very simple Sub for explanation purposes (you can see it clearly bellow)</p>
  
  <pre><code>Sub dd()
    Dim i As Integer
    Dim Top As Range
    Set Top = Range("A1:A4")
    i = Top.Count
    MsgBox i
  End Sub
  </code></pre></li>
  <li><p>Count property "counts" and returns the number of objects in the collection</p></li>
  </ol>
  
  <p>Alright hold that childish example in your mind for a minute and proceed bellow...</p>
  
  <hr>
  
  <p>Now lets say we are creating a custom object in VBA so we open a Class Module and name it <strong>clsEmployee</strong>. Now the object has 4 properties, according to the book, so we are declaring them like variables inside the class module:</p>
  
  <pre><code>Public EmpName as String
  Public EmpID as String
  Public EmpRate as Double
  Public EmpWeeklyHrs as Double
  </code></pre>
  
  <p>There is also a method so we type her in the Class module</p>
  
  <pre><code>Public Function EmpWeeklyPay as Double
    EmpWeeklyPay = EmpRate * EmpWeeklyHrs
  End Function
  </code></pre>
  
  <p>Now if we go to a normal module reference and instantiate the object by typing Employee the Intellisense window...</p>
  
  <p><img src="https://i.stack.imgur.com/Qv2w5.png" alt="enter image description here"></p>
  
  <p>...shows us these procedures and functions</p>
  
  <p>But <strong>how</strong> would you create a custom property like Count? As you can see in the graphic example in the first picture the Count property engages in some sort of <em>logic steps</em> and counts the cells parsing them one by one in the collection and returns the number 4 in the MsbBox. It can make only sense that these <em>logic steps</em> are in fact somehow <em>hard-coded</em> in the machine. You cannot declare that kind of property in the Class module by simply typing:</p>
  
  <pre><code>Dim Count as Integer
  </code></pre>
  
  <p>according to the absurd axiom in the book which says:</p>
  
  <pre><code>Properties are variables that can be declared Private or Public.
  </code></pre>
  
  <p>It would also be very revealing the fact that Count Property <strong>is NOT being equaled</strong> with anything in the code in picture. That means Count property is not a "straw" property it needs some logic to parse the cells in the Range("A1:A4") and say there are 4 cells. I just cannot see how i would create such a custom object with by typing in the Class module: Dim Count as Integer</p>
  
  <p><strong>How</strong> you would create <em>in custom objects</em> properties like Name, Value or Count without some <em>procedures</em> to tell the compiler what to do by just typing 'straw' declaration in the Class module?</p>