title: Unnamed Default Property
body: <p>In VBScript, some built in objects use an unnamed property.  Some Examples:</p>
  
  <pre><code>Set Dict = Server.CreateObject("Scripting.Dictionary")
  Set RS = GetEmloyeesRecordSet()
  
  Dict("Beer") = "Tasty"  ' Same as Dict.Item("Beer") = "Tasty"
  Dict("Crude Oil") = "Gross" ' Same as Dict.Item("Crude Oil") = "Gross"
  
  Response.Write "The First Employee Is: " &amp; RS("Name") ' Same as RS.Fields("Name")
  </code></pre>
  
  <p>How can I use this same syntax in my own classes?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is a working, stand-alone example of how to do this, a simple wrapper for Scripting.Dictionary.  Note the use of "Let" to allow the d("key") = "value" syntax.  Of course credit goes to Thom for providing the answer.</p>
  
  <pre><code>&lt;%
  Class DictWrapper
      Private Dict
  
      Private Sub Class_Initialize()
          Set Dict = Server.CreateObject("Scripting.Dictionary")
      End Sub 
  
      Private Sub Class_Terminate()
          Set Dict = Nothing
      End Sub 
  
      Public Property Get Count
          Count = Dict.Count
      End Property
  
      Public Default Property Get Item( Key )
          Item = Dict(Key)
      End Property
  
      Public Property Let Item( Key, Value )
          Dict(Key) = Value
      End Property
  
      Public Sub Add( Key, Value )
          Dict.Add Key, Value 
      End Sub 
  
  End Class
  
  Dim d : Set d = New DictWrapper
  d.Add "Beer", "Good"
  Response.Write d("Beer") &amp; "&lt;br&gt;"
  d("Beer") = "Bad"
  Response.Write d("Beer")
  %&gt;
  </code></pre>