title: Using Objects in a dictionary in vb.net
body: <p>This is how I Check if my dictionary <code>occurences</code>  already contains a key and a value and assign keys and values to it... but I need another value, so how do I use the object here?</p>
  
  <pre><code>Occurences.Add(xRows.Cells(4).Value.ToString(), Object)
  </code></pre>
  
  <p>Somehow like this:</p>
  
  <pre><code>occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + &lt;"1st object value here"&gt;)
  </code></pre>
  
  <p>But this is how I currently do it which only  has a key and a value but I need something like key, object which has (value, value), something like that:</p>
  
  <p>Actual code:</p>
  
  <pre><code>If (occurences.ContainsKey(xRows.Cells(4).Value.ToString())) Then
      occurences(xRows.Cells(4).Value.ToString()) = Double.Parse(occurences(xRows.Cells(4).Value.ToString()).ToString()) + Double.Parse(xRows.Cells(7).Value.ToString())
  Else
      occurences.Add(xRows.Cells(4).Value.ToString(), Double.Parse(xRows.Cells(7).Value.ToString()))
  End If
  
  Next
  </code></pre>
  
  <p>Then i have another code for insert where i need to use the 2nd value of the object.</p>
  
  <pre><code>Using commm As New MySqlCommand()
      With commm
           .Parameters.Clear()
           .Parameters.AddWithValue("@iBrnchCde", cmbBrnchCode.Text)
           .Parameters.AddWithValue("@iFCode", pair.Key)
           .Parameters.AddWithValue("@iDesc", &lt;"2nd OBJECT VALUE HERE"&gt; )
           .Parameters.AddWithValue("@iQty", pair.Value)
           .CommandText = oInsertString
           .Connection = _conn
           .CommandType = CommandType.Text
       End With
       commm.ExecuteNonQuery()
  End Using
  </code></pre>