title: Is there a way to set a common set of properties for a group of classes in VBA?
body: <p>I am working on a project in <a href="/questions/tagged/excel-vba" class="post-tag" title="show questions tagged &#39;excel-vba&#39;" rel="tag">excel-vba</a> where I have a number of classes which are used to query data from various sources. As these classes are similar I am trying to determine if using a common interface and using the <code>Implements</code> statement is a feasible option for me. I am fairly new to OOP in general (though I am trying to learn in a non-VBA language), and I understand that OOP in VBA leaves alot to be desired. </p>
  
  <p>The information that I have been reading basically states that you set up your Interface Class, which we will call <code>IBaseInfo</code>:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Property Let LocationData(ByRef locDATA As udtLocData)
  End Property
  
  Public Property Let ReferenceDate(ByVal dteDATE As Date)
  End Property
  </code></pre>
  
  <p>Then you actually implement <code>IBaseInfo</code> in your class, which we will call <code>clsRate5pt</code>:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Implements IBaseInfo
  
  Private Property Let IBaseInfo_LocationData(Byref RHS As udtLocData)
  
  End Property
  
  Private Property Let IBaseInfo_ReferenceDate(ByVal RHS As Date)
  
  End Property
  </code></pre>
  
  <p>Where I am getting confused is how I actually access the properties from the object level in a module. What I am getting from the reference on VBA polymorphism at <a href="http://msdn.microsoft.com/en-us/library/aa240846(v=VS.60).aspx" rel="nofollow noreferrer">msdn</a> is that I would need to actually declare a variable of type <code>IBaseInfo</code>, set it equal to an object of type <code>clsRate5pt</code> and access the properties through that variable. Such as:</p>
  
  <pre class="lang-vb prettyprint-override"><code>Sub TestIFace()
  
      Dim o5PT As clsRate5Pt
      Dim oInfo As IBaseInfo
  
      Set o5PT = New clsRate5Pt
      Set oInfo = o5PT
  
      oInfo.LocationData = '// Some location Data
      oInfo.ReferenceDate = '// Some Reference Date
  
  End Sub
  </code></pre>
  
  <p>Is there a way to set a common set of interfaces for a group of classes in <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged &#39;vba&#39;" rel="tag">vba</a>? Is <code>Implements</code> the way to go, and if so, what am I doing wrong? </p>
  
  <p>It just seems counter-intuitive to access the properties through a different object. If <code>clsRate5pt</code> is "implementing" the interface, shouldn't there be a way to access those properties through <code>clsRate5pt</code>?</p>