title: How to use the Implements in Excel VBA
body: <p>I'm trying to implement some shapes for an engineering project and abstract it out for some common functions so that I can have a generalized program.</p>
  <p>What I'm trying to do is have an interface called <code>cShape</code> and have <code>cRectangle</code> and <code>cCircle</code> implement <code>cShape</code></p>
  <p>My code is below:</p>
  <p><strong><code>cShape</code> interface</strong></p>
  <pre><code>Option Explicit
  
  Public Function getArea()
  End Function
  
  Public Function getInertiaX()
  End Function
  
  Public Function getInertiaY()
  End Function
  
  Public Function toString()
  End Function
  </code></pre>
  <p><strong><code>cRectangle</code> class</strong></p>
  <pre><code>Option Explicit
  Implements cShape
  
  Public myLength As Double ''going to treat length as d
  Public myWidth As Double ''going to treat width as b
  
  Public Function getArea()
      getArea = myLength * myWidth
  End Function
  
  Public Function getInertiaX()
      getInertiaX = (myWidth) * (myLength ^ 3)
  End Function
  
  Public Function getInertiaY()
      getInertiaY = (myLength) * (myWidth ^ 3)
  End Function
  
  Public Function toString()
      toString = &quot;This is a &quot; &amp; myWidth &amp; &quot; by &quot; &amp; myLength &amp; &quot; rectangle.&quot;
  End Function
  </code></pre>
  <p><strong><code>cCircle</code> class</strong></p>
  <pre><code>Option Explicit
  Implements cShape
  
  Public myRadius As Double
  
  Public Function getDiameter()
      getDiameter = 2 * myRadius
  End Function
  
  Public Function getArea()
      getArea = Application.WorksheetFunction.Pi() * (myRadius ^ 2)
  End Function
  
  ''Inertia around the X axis
  Public Function getInertiaX()
      getInertiaX = Application.WorksheetFunction.Pi() / 4 * (myRadius ^ 4)
  End Function
  
  ''Inertia around the Y axis
  ''Ix = Iy in a circle, technically should use same function
  Public Function getInertiaY()
      getInertiaY = Application.WorksheetFunction.Pi() / 4 * (myRadius ^ 4)
  End Function
  
  Public Function toString()
      toString = &quot;This is a radius &quot; &amp; myRadius &amp; &quot; circle.&quot;
  End Function
  </code></pre>
  <p>The problem is that whenever I run my test cases, it comes up with the following error:</p>
  <blockquote>
  <p>Compile Error:</p>
  </blockquote>
  <blockquote>
  <p>Object module needs to implement '~' for interface '~'</p>
  </blockquote>