title: VBA - Dictionary search - type mismatch
body: <p>So I'm learning how to use Dictionaries but I have encountered a type problem. In the code below I get an error. </p>
  
  <blockquote>
    <p>Type mismatch</p>
  </blockquote>
  
  <p>Each time I try to call <code>If Not target.SearchItem(sKey) Is Nothing Then</code>. I want it to return a object then if it isn't <code>Nothing</code> I can convert it back to long.</p>
  
  <pre><code>For Each target In dList.getArray
      For Each key In aList.getArray(1).getKeys
          sKey = CStr(key)
              'Error occurs here - as Type mismatch
              If Not target.SearchItem(sKey) Is Nothing Then
                  cData.setData(sKey) = CLng(target.SearchItem(sKey))
                  target.removeData = sKey
               Else
                   'if value doesn't exists it will just be 0
                    cData.setData(sKey) = 0
                End If
      Next key
  Next target
  </code></pre>
  
  <p><code>data</code> is my dictionary that is in a separate class:</p>
  
  <pre><code>Property Get SearchItem(name As String) As Variant
      If data.exists(name) Then
          'becomes a Variant/Integer - data(name) is a Variant/long
          Set SearchItem = CVar(data(name))
      Else
          'Should return Nothing if item doesnt exist
          Set SearchItem = Nothing
      End If
  End Property
  </code></pre>
  
  <p>Update: To explain the problem I bit more. Even though I return it as a variant it will still be partly Integer and therefor If Not <code>target.SearchItem(sKey) Is Nothing Then</code> will return mismatch as it needs an object and VBA doesn't read is as a variant or something. Is there anything like Nothing, null or equally that works for a long? That would solve the problem.</p>
  
  <p>This code below returns a long as I want it to, but I can't use -99 as it would corrupt the data analyse. It needs to be something that isn't a value</p>
  
  <pre><code>Property Get SearchItem(name As String)
      If data.exists(name) Then
          SearchItem = data(name)
      Else
          'SearchItem = Nothing
           SearchItem = -99
      End If
  End Property
  </code></pre>