title: How do Class definitions work in VBA
body: <p>As i am trying to learn VBA, Classes are blasting me some heavy duty pain!!!</p>
  
  <p>Here is something from one of my VBA books (VBA and Macros Microsoft Excel 2010 - Bill Jelen at page 497) which is absolutely bizzare and peculiar:</p>
  
  <ol>
  <li><p>We open a class module in VBE</p></li>
  <li><p>And we are writing the 4 properties and 1 method of the custom object in the class module <code>clsEmployee</code>:</p>
  
  <pre><code>'Properites   
  Public EmpName As String             
  Public EmpID As String   
  Public EmpRate As Double         
  Public EmpWeeklyHrs As Double
  
  'Methods   
  Public Function EmpWeeklyPay() As Double  
      EmpWeeklyPay = EmpRate * EmpWeeklyHrs  
  End Function
  </code></pre></li>
  <li><p>The book writes that the custom object is now complete </p></li>
  <li><p>Now the book goes to open a simple module (not a class module) to reference the custom object from another module, so it goes:</p>
  
  <pre><code>Dim Employee as clsEmployee
  
  Set Employee = New clsEmployee
  </code></pre></li>
  <li><p>Not it presents all the code block. Really awkward thing here is that the <em>Dim Employee as clsEmployee</em> is <strong>outside of the sub procudure! Why?</strong> (So this could be seen as the minor question)</p>
  
  <pre><code>Option Explicit
  
  Dim Employee as clsEmployee 'why is this outside of the code block?
  
  Sub EmpPay()
      Set Employee = New clsEmployee
  
      With Employee
          .EmpName = "Tracy Syrstad"
          .EmpID = "1651"
          .EmpRage = 25
          .EmpWeeklyHrs = 40
  
          MsgBox .EmpName &amp; " earns $" &amp; .EmpWeeklyPay &amp; " per week."
      End With
  
  End Sub
  </code></pre></li>
  <li><p>The book graciously says:</p></li>
  </ol>
  
  <p>The procedure declares an object <code>Employee</code> as a new instance of <code>clsEmployee</code>. It then assigns values to the four properties of the object and generates a message box displaying the employee name and weekly pay. The object’s method, <code>EmpWeeklyPay</code>, is
  used to generate the displayed pay.</p>
  
  <h2>I'm stuck here people</h2>
  
  <p>As far as i know when we put (an original VBA-made and not a custom one from the class module) a property after an object for example<br>
      <code>Application.Name</code><br>
  ...VBA returns a String value that represents the name of the object. OK, so VBA somehow knows how to do this. But I just cannot understand <strong>how</strong> is it possible in the books paradigm to <strong>create a custom</strong> property <em>just</em> by typing with nothing hard-coded</p>
  
  <pre><code>Public EmpName As String
  Public EmpID As String
  Public EmpRate As Double
  Public EmpWeeklyHrs As Double
  </code></pre>
  
  <p>...<strong>just as Name property differs from Value property, what creates up there 4 different properties? I mean how are their mechanics are different? What makes property <code>EmpName</code> different to <code>EmpID</code>???</strong> For all I know they are just variables declared in the class module. How can we create custom object properties just by declaring variables in the class module??? Shouldn't we somehow input the mechanics, a demarcation, the chassis if you will, so when I use/set <code>EmpID</code> it will go to look the employees ID and not his name. What is actually assuring me that when I call the <code>EmpRate</code> it won't go for the <code>EmpWeeklyHrs</code> it's the same data type and there is no other type of code in their "blueprint" the class module to stop things from getting unreliable. There's surely something hardcoded that makes <code>Value</code> and <code>Name</code> property different how can we only declare variables in the custom made object? it makes no sense to me</p>
  
  <p><strong>thank you for watching my long long long question</strong></p>