title: VB.NET Array/Hashtable Issue
body: <p>I am trying to make an array of hashtables. I don't know if this is the best solution, in PHP I would just do a multi-dim array, but it's not so easy in .NET. I am pretty new o VB, so if there is a better solution for this please explain.</p>
  
  <p>I have 2 emails fields for a contact, and a contact can have many. I just want to load in the first two on the edit page for editing, whatever they may be. </p>
  
  <pre><code>Private Sub loadPrimaryContactEmails(ByVal db As CRMDataDataContext, ByVal contactID As Guid)
          Dim q = (From ce In db.ContactEmails Where ce.ContactID = contactID Select ce).Take(2)
          Dim Emails As Array
          Dim count = 0
          For Each email In q
              Emails(count) = New Hashtable
              Emails(count).Add("email", email.Email)
              Emails(count).Add("label", email.Label)
              Emails(count).Add("id", email.ContactEmailID)
              count = count + 1
          Next
          txtPCEmail1.Text = Emails(0).Item("email")
          txtPCEmail1Label.Text = Emails(0).Item("label")
          lblEmail1ID.Text = Emails(0).Item("id")
  
          txtPCEmail2.Text = Emails(1).Item("email")
          txtPCEmail2Label.Text = Emails(1).Item("label")
          lblEmail2ID.Text = Emails(1).Item("id")
      End Sub
  </code></pre>
  
  <p>I get the error the first time I try to reference my array:</p>
  
  <pre><code>txtPCEmail1.Text = Emails(0).Item("email")
  </code></pre>
  
  <p>The error is: </p>
  
  <pre><code>Object variable or With block variable not set.
  </code></pre>
  
  <p>It builds, so I thought it might work. I can't just loop through my datasource because I have to explicitly set textbox fields. Is there a better way to go about doing this? Or is there a way to make an array of hashtables work?</p>
  
  <p>EDIT - here is the good code:
  So I went w/ the HybridDictionary...</p>
  
  <pre><code>Private Sub loadPrimaryContactEmails(ByVal db As CRMDataDataContext, ByVal contactID As Guid)
          Dim q = (From ce In db.ContactEmails Where ce.ContactID = contactID Select ce).Take(2)
          Dim Emails As New HybridDictionary()
          Dim count = 1
          For Each email In q
              Emails.Add("email" + NCStr(count), email.Email)
              Emails.Add("label" + NCStr(count), email.Label)
              Emails.Add("id" + NCStr(count), email.ContactEmailID)
              count = count + 1
          Next
          txtPCEmail1.Text = Emails("email1")
          txtPCEmail1Label.Text = Emails("label1")
          lblEmail1ID.Text = Emails("id1")
  
          txtPCEmail2.Text = Emails("email2")
          txtPCEmail2Label.Text = Emails("label2")
          lblEmail2ID.Text = Emails("id2")
      End Sub
  </code></pre>
  
  <p>SO yeah, kind of a hack, but I don't feel like I should have to making special methods just to load some data into a dictionary or array or whatever.</p>