Using A HashTable Key?
Feb 22, 2009
I'm using a HashTable that stores information typed by the user in textboxes on a form. There are 4 textboxes on my form including, Name, Number, account representative, and total count of things added. Besides the text boxes there are 3 buttons on the form, one or adding a record, one for deleting one, and one for display the selected name from the listbox.
Everything pretty much works for me at this point, but I just have one question. When the record is input into the listbox it is supposed to display the users name he or se just entered in the name textbox. Now then, our professor wants us to use the number for the keyString for the HashTable.
That is the problem, if I use the number, instead of the name displaying in the listbox, the number displays. Is there a way to display the name in the listbox instead of the number? Once I have assigned the number as the keyString, am I stuck displaying that value only?
View 1 Replies
ADVERTISEMENT
Jul 20, 2010
I have a hashtable in VB.NET and I need to get the string value of a key from it's value. For example, if I do: hashtable.add("string1","string2") How would I get the value "string1" if I had "string2"?
View 2 Replies
Jan 1, 2012
Can you put a hashtable in another hashtable? I'm trying to make Tetris and to represent the grid of the gamefield I want to have an hashtable within another hashtable. The code is as followed
Public Tetrisfield As Hashtable
Public TetrisRow As Hashtable
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
[Code].....
View 3 Replies
Nov 2, 2009
I have a hash table in which the key is of type Point and the value is of type PieceOfBoard. PieceOfBoard is derived from PictureBox. How do I serialize this hashtable to save it to a file?Do I need to add anything to the PieceOfBoard class?
View 3 Replies
Apr 21, 2009
I been learning basics of generics and it looks like it can really improve the performance of the application. But, I am not able to see the generic equivalent of Hashtable. share some sample C# code for creating generic hashtable classes. I need this for a demo.
View 5 Replies
Oct 12, 2010
Is it possible to create a hashtable "pre-populated" with values?[code]...
View 2 Replies
Jan 27, 2010
I am using a hashtable to cache incoming UDP messages before my application processes them. After adding pairs to the hashtable, I am experiencing strange behaviour when interogating the collection, such that a containsKey() enquiry returns false, even though the key exists and is visible in the locals window. Spelling etc is correct, manually calling GetHashCode on the key (String) at each point (add() and containsKey()) is returning different values for the same key. To complicate things more, some keys are matched successfully.
View 2 Replies
Nov 3, 2010
I currently have a ASP.NET Website and a Windows Service doing some work together.It consists in running some processes either using scheduling or on-demand requests.Basically before i had the windows service i used a Shared Hashtable to register all the on-demand requests and avoid duplicate requests for the same ID. I tought i could use the same hashtable to add the scheduled requests also... but somehow they are being created in separated hashtable's.I think its because the windows service uses a diferent instance of the website.
PS: in the hashtable i save full class objects for future reference so the solution must be able to achieve the same.
View 3 Replies
May 9, 2011
I was using the For Each frm as From In Application.OpenForms but it seemed a bit inefficient to loop thru every open form when I already knew what I was looking for. After some googling I found some information about hashtables so I used the following code. This code works as long as another form, say form3, isn't open with the same ID. What I am trying to figure out is, why is the hsh.contains only looking at the key instead of looking at the key/value pair?
Form1
Public hsh as New HashTable
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
[code].....
View 2 Replies
Dec 13, 2010
I am making a small tool that require some calculation. I am using hashtable to store values that I need to calculate. This tool continuously extract data on specific time interval(30 seconds) from webpage and add those data into the hashtable. Now the problem is I need to store the previous extraction data and when new extraction occurs, I need to deduct the previous data from new data.
[Code]...
On first run it shows the result of Data3 = 100 which is currect. But on second run I need to redefine the value of Data2 = Data1 . So I need a result of Data3 = 0 on second run. This may not be the proper way to do this sort of operation. I have also tried using listbox, listview and even textfile to store the Data2 and recall that on second run. But could not make it possible.
This is the last phase of my tool and I am stuck with it.
View 1 Replies
May 7, 2012
I have a scenario at work where we have several different tables of data in a format similar to the following:
Table Name: HingeArms
Hght Part #1 Part #2
33 S-HG-088-00 S-HG-089-00
41 S-HG-084-00 S-HG-085-00
[code]....
Where the first column (and possibly more) contains numeric data sorted ascending and represents a range to determine the proper record of data to get (e.g. height <= 33 then Part 1 = S-HG-088-00, height <= 41 then Part 1 = S-HG-084-00, etc.)
I need to lookup and select the nearest match given a specified value. For example, given a height = 34.25, I need to get second record in the set above:
41 S-HG-084-00 S-HG-085-00
These tables are currently stored in a VB.NET Hashtable "cache" of data loaded from a CSV file, where the key for the Hashtable is a composite of the table name and one or more columns from the table that represent the "key" for the record. For example, for the above table, the Hashtable Add for the first record would be:
ht.Add("HingeArms,33","S-HG-088-00,S-HG-089-00")
This seems less than optimal and I have some flexibility to change the structure if necessary (the cache contains data from other tables where direct lookup is possible... these "range" tables just got dumped in because it was "easy"). I was looking for a "Next" method on a Hashtable/Dictionary to give me the closest matching record in the range, but that's obviously not available on the stock classes in VB.NET. what I'm looking for with a Hashtable or in a different structure? It needs to be performant as the lookup will get called often in different sections of code.
View 3 Replies
Nov 2, 2010
This is similar to How to keep the order of elements in hashtable, except for .NET. Is there any Hashtable or Dictionary in .NET that allows you to access it's .Index property for the entry in the order in which it was added to the collection?
View 5 Replies
Jul 23, 2010
I try to convert names and values parameters of function into a hashtable. For name of parameter, it's ok, but not for value.
Function test(ByVal param1 As String, ByVal param2 As String) As Hashtable
Dim hash As Hashtable = New Hashtable
Dim stFrame As New StackFrame
[Code]....
There is a property to get default value of parameter (if optional) with param.DefaultValue but how to get current value ?
View 1 Replies
Dec 8, 2009
recently started converting our project from 1.1 to 2.0
It was fine with the following:
Public ghtAllAppMsgs As New Hashtable(300)
Now it is complaining to change to the following is this the right way:
Public ghtAllAppMsgs As New System.Collections.Hashtable(300)
This is under global.vb class file: here are the imports i already had in this file:
Imports Microsoft.Web.UI.WebControls
Imports Microsoft.Web.UI.WebControls.MultiPage
Imports System.Web
[Code]......
View 1 Replies
Feb 16, 2010
i have a multi-client/server app that needs to use a hashtable but i am getting an unexpected result because each timei call a sub from form1 the hashtable get recreated and erases all the data. [code]
View 12 Replies
Jan 25, 2012
Is there a VB equivalent to PHP's print_r available? I have a very large and complex hashtable that I would like printed out.
View 3 Replies
Dec 25, 2009
I am making a small tool that require some calculation. I am using hashtable to store values that I need to calculate. This tool continuously extract data on specific time interval(30 seconds) from webpage and add those data into the hashtable. Now the problem is I need to store the previous extraction data and when new extraction occurs, I need to deduct the previous data from new data.Here is the process I am currently following:
Dim MyTable as New Hashtable
MyTable.Add("Data1","200")
MyTable.Add("Data2","100")
[code].....
View 5 Replies
Jan 12, 2011
I'm helping a friend port some code that I have written in Java to Visual Basic.NET. VB.NET is not my language of choose, so I am entirely new to it's quirks. How can I display keys from a HashTable in a ListBox?
View 2 Replies
Jun 19, 2010
In VB.NET, how can I convert the following string into some kind of key/value type such as a Hashtable, Dictionary, etc?"Name=Fred;Birthday=19-June-1906;ID=12345".I want to extract Birthday or ID without having to split the string into an array.I'd prefer not to split the string into an array in case the format of the string changes later.I don't have control over the string.What if someone switches the order around or adds another element?
View 6 Replies
Oct 18, 2010
I need to place objects of various types in a "collection" and be able to:
1) Change the value of a property on any of the objects by using it's key.
2) Read the objects in the order they were placed in the "collection"
3) Read the objects in the reverse order they were placed in the "collection"
My findings so far:
1) Collection won't work because Item property is read only
2) It seems that Hashtable and dictionary won't work because I cannot iterate through them in reverse order.
3) Stack won't work for obvious reasons.
Is there a collection like data structure that has satisfies the requirements?
View 16 Replies
Jun 3, 2011
I want to make a hashtable of object references and I want a different object's reference to be the key. How can I do this in vb.net? In java (assuming I am using the default toString method and that add() takes a string as a key and an object ref as the value) this would be something like: hashtable.add(obj1.toString(), obj2)
I do not want to use a vb.net gethashcode() function because I want deep clones of objects to have different identifiers. A related question is what is the default toString in vb.net? How can I get a string that represents an object reference in vb.net?
View 3 Replies
Feb 26, 2011
I have a hashtable that stores sports players: key = jersey number, value = an array of information...and what I am trying to do is put this information into combobox (but only showing a certain array elements), so for example say this was the information stored in the hashtable:
(key,{value})
"01",{"john smith","125lbs","qb"}
"02",{"john doe","205lbs","rb"}
so what I have done is created an arraylist that will store the items in the combobox.but my problem happends when I try to loop through the array from the hashtable values.
(playerlisting is the hashtable)
Dim playerlist As New ArrayList
[code]....
The above works, however since it's a foreach loop I cannot specify which array indexes I want to add onto the "listitem" string.
Dim arr As Array = CType(item.Value, Array)
For i = 0 To arr.Length - 1
listitem += arr(i) & " "
Next
But, when I try a simple forloop instead I get a "late binding" error with the 3rd line. Even when I cast the arr(i) as a string I get the error. What needs to be changed?
View 3 Replies
Oct 26, 2010
The field's names of hashtable are same of fields adodb.recordsetHow can i import the fields value of hashtable in fields adodb.recordset without do it manually?[code]....
View 1 Replies
Dec 3, 2007
how to save hashtable object to data or text file like (sample.dat or sample.txt)
i got this class Name Book.
[code...]
if i run this application it works, but if i close the application the hashtable items will be erase.i want to save the items to dat file or txt file.i got some idea but it doesnt work, i use the file stream :[code...]
View 2 Replies
Dec 11, 2010
I am making a small tool that require some calculation. I am using hashtable to store values that I need to calculate. This tool continuously extract data on specific time interval(30 seconds) from webpage and add those data into the hashtable. Now the problem is I need to store the previous extraction data and when new extraction occurs, I need to deduct the previous data from new data.Here is the process I am currently following:
HTML
Dim MyTable as New Hashtable
MyTable.Add("Data1","200")
MyTable.Add("Data2","100")
[code]....
On first run it shows the result of Data3 = 100 which is currect. But on second run I need to redefine the value of Data2 = Data1 . So I need a result of Data3 = 0 on second run. This may not be the proper way to do this sort of operation. I have also tried using listbox, listview and even textfile to store the Data2 and recall that on second run.
View 2 Replies
Mar 24, 2010
I am using a Hashtable which stores unique names and objects associated with those names. Now those objects have a property called "IsDynamic" and some of them have it set to false whie some of them have it set to true. So when I retrieve any object using the key property, it goes to find me that object. How do I override that find method?
[Code]...
View 6 Replies
Dec 19, 2011
I have a program that are multiple thread. Each thread calculate some data independently. however, they will need share a hashtable which controls a hardware resource. because the resource is limited, so, it may need lock the resource for a thread, and then release it when thread is finished. and the resource can not be reused immediately, will have to wait for some time, say 5 or 10 minutes, for the device to reset.
View 3 Replies
Aug 6, 2009
I'm trying to add some extra key/value pairs to a combo box using VB.NET. The initial item list is generated from a hashtable, which contains a collection of objects.I've managed to add the extra values to the box using the Add method, however I now run into problems when reading back the selected item from the combo box because some list items are objects, while others are strings.
My best option seems to be to load the initial data as key/value pairs by looping through the hashtable, however this doesn't seem to be working too well either because I'm still getting errors.I'm getting frustrated because it's taking me hours to do something that should take 5 minutes!
View 1 Replies
Jan 25, 2012
how to sort the group of files in the directory using Hashtable by values?
i'll have more than 500 no of files in the below format:
prod_orders_XXX_<TimeStamp>.dat
XXX = symbol of the product and the length may varies.
<TimeStamp> = date and time
Multiple files for the same XXX are possible with different time stamps.
Here are some examples:
prod_orders_abc_20122001083000.dat
prod_orders_abc_20122001083111.dat
prod_orders_xyz_20122001093157.dat
[Code]......
I have posted a similar question before but this time i need this specificly using Hashtable.
View 1 Replies
Mar 24, 2010
I've defined a setting called CustomActions as a System.Collection.Hashtable. I also have a form with two textboxes (Name & CommandLine) that I want to add as a Key/Value pair to the CustomActions settingHowever, when I come to add the kvp to Hashtable I get the dreaded "Object reference not set to an instance of an object". I know what the error means I just don't see why it's relevant here.
Dim CustomActionForm As New DefineCustomAction
If CustomActionForm.ShowDialog = System.Windows.Forms.DialogResult.OK ThenMy.Settings.CustomActions.Add(CustomActionForm.txt_CAName.Text,
[code].....
View 1 Replies