Reset values in HashTable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thesti
    New Member
    • Nov 2007
    • 144

    Reset values in HashTable

    hello,

    i have a hashTable of which values are needed to be reset. i've tried using the DictionaryEntry to iterate through each element in the hashTable and setting their values to 0, but it seems that it doesn't work.

    Code:
    For Each item As DictionaryEntry In hashQty
                item.Value = 0
            Next
    afer the code above is executed, the value of each element in hashQty is not 0.


    Thank you
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    Originally posted by thesti
    hello,

    i have a hashTable of which values are needed to be reset. i've tried using the DictionaryEntry to iterate through each element in the hashTable and setting their values to 0, but it seems that it doesn't work.

    Code:
    For Each item As DictionaryEntry In hashQty
                item.Value = 0
            Next
    afer the code above is executed, the value of each element in hashQty is not 0.


    Thank you
    Try putting item after Next so it looks like this;

    Code:
    For Each item As DictionaryEntry In hashQty
                item.Value = 0
            Next item
    Because if you don't put that, I don't think it loops through all of them.

    Here's the example from MSDN's Hashtable Class page.

    Originally posted by MSDN
    Code:
    For Each de as DictionaryEntry In myHashtable
       ...
    Next de
    Notice the Next de on the 3rd line...

    joedeene

    Comment

    Working...