title: Error returning object instance from function in VBA
body: <p>I'm trying to instantiate an object and return it from a function. The class I'm working with is one that I've created. However when I try to set an Object to what was returned from the function I get an error. What am I doing wrong?</p>
  
  <pre><code>Function CreateBlah(NAME As String, Count As Integer, val As String) As Blah
      Dim b As Blah
      Set b = New Blah
      bkmrk.Initialize NAME, Count, val
      MsgBox (bkmrk.NAME)
      CreateBlah = bkmrk
  End Function
  </code></pre>
  
  <p>Then in the other function...</p>
  
  <pre><code>Dim bmrk As Blah
  Set bmrk = CreateBlah("Test", 1, Trim(AString))
  </code></pre>
  
  <p>I also tried...</p>
  
  <pre><code>Dim bmrk As Object
  Set bmrk = CreateBlah("Test", 1, Trim(AString))
  </code></pre>
  
  <p>I'm new to VBA, can anyone tell me what I'm doing wrong?</p>