473,836 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reset values in HashTable

144 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. For Each item As DictionaryEntry In hashQty
  2.             item.Value = 0
  3.         Next
  4.  
afer the code above is executed, the value of each element in hashQty is not 0.


Thank you
Nov 2 '08 #1
1 1450
joedeene
583 Contributor
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.

Expand|Select|Wrap|Line Numbers
  1. For Each item As DictionaryEntry In hashQty
  2.             item.Value = 0
  3.         Next
  4.  
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;

Expand|Select|Wrap|Line Numbers
  1. For Each item As DictionaryEntry In hashQty
  2.             item.Value = 0
  3.         Next item
  4.  
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.

Expand|Select|Wrap|Line Numbers
  1. For Each de as DictionaryEntry In myHashtable
  2.    ...
  3. Next de
Notice the Next de on the 3rd line...

joedeene
Nov 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
30144
by: Ken | last post by:
How can I reset the initial form variables that are set with session statements when clicking on a button? I tried this but the function was not called: <?PHP function reset_form($none) { $_SESSION = array(); } ?> <form enctype="multipart/form-data" name="company_info" method="post" action="add_pic.php">
0
1229
by: John Meredith via .NET 247 | last post by:
Hi all, I used all your info to come up with the following conclusion when I needed to modify my Hashtable object. 1) Create an ArrayList from the Hashtable keys so that we have something to iterate around without involving the Hashtable. 2) Use a foreach or a for loop to iterate around each ArrayList item and change the Hashtable values as we need. ArrayList keyList = new ArrayList(myHashTable); for (int i=0; i < myHashTable.Count;...
0
2254
by: Ricardo Pereira | last post by:
Hi, I wrote a simple program to test the "out-of-the-box" functionalities of the CMAB (Configuration Management Application Block). After having added 2 values to an hashtable, and having written that hashtable (using the XmlHashtableSectionHandler) to an XML file (using the XmlFileStorage) I try to read back the hashtable with those values. I am adding a "string" value (with a string key) and a "double" value (also with a string key) to...
3
5879
by: Frank | last post by:
Hi! I'm kinda stuck here. I have an Hashtable with with my custom "Item" Object. The key used in the Hashtable is the "Item.Id", i have selected this key because with a lot of functions i can get the right object from the hashtable really fast. But now i need a function whom can get an object from the hashtable based on the values each "Item" object holds. ("Item.ColorId","Item.SizeId","Item.OtherId"), but i can't identify the object...
8
59520
by: SenthilVel | last post by:
how to get the corresponding values for a given Key in hashtable ??
1
1647
by: Ryan Liu | last post by:
Hashtable.GetEnumerator is not thread safe, but what about I write I loop go though Hashtable.Values, is that thread saft? Thanks a lot!
2
2658
by: andrewcw | last post by:
I have a reason to resuse hashtables and I'd like to set the values to null without having to reload the keys.- > which is what the clear method does. If I try a foreach construct I get an error that I cannot alter the value. The documentation for using an enumerator and moveNext also have the same restriction. WONT WORK: private Hashtable hashValueNuller(Hashtable theHash) {
3
5442
by: hiddenhippo | last post by:
Hi, I have a class which contains all my constant values such as; public static readonly string strStringOps = {"Equals","Not Equals","Contains"}; The above nicely assigns the values into the string array. However I'm looking for a way of achieving the same results whilst using a hashtable; for example
12
3368
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I'm creating a hashtable of a list of users in AD. The keys are UserID and Password. I want to loop through the table to compare the userID and password with values that a user has entered. Ideally I'd want to run through the records until I find one that matches with the entered UserID and then compare passwords. I've googled and I can't really find any examples of how to do this.
0
9813
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10584
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10248
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7782
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5817
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4446
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.