By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Embedded Hashtables

P: n/a
Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't delete
the values of the first hashtables that I want saved into the cust hashtable
when I do a clear?

Thanks,
Curtis
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I solved my problem by using the .clone method of the hashtables like so:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines.Clone)
cust.Add("ABC", invoice.Clone)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines.Clone)
cust.Add("BBB", invoice.Clone)

Curtis

"Curtis" <cs*****@hotmail.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...
Does anyone know the proper method to save information to embedded
hashtables.

I am trying to save parent/child information to hashtables but I am not
getting the correct results I have made a very simplified example of
problem with the following code:

Dim cust As New Hashtable
Dim invoice As New Hashtable
Dim invoiceLines As New Hashtable
invoiceLines.Add(1, "500")
invoiceLines.Add(2, "1000")
invoice.Add("Inv123", invoiceLines)
cust.Add("ABC", invoice)
invoiceLines.Clear()
invoice.Clear()
invoiceLines.Add(1, "123")
invoiceLines.Add(2, "10")
invoice.Add("Inv222", invoiceLines)
cust.Add("BBB", invoice)

Is there a way to correctly save this information so that it doesn't
delete the values of the first hashtables that I want saved into the cust
hashtable when I do a clear?

Thanks,
Curtis

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.