Using A Hashtable To Keep Track Of Forms?

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


ADVERTISEMENT

Forms :: Resolved Search And Display ArrayList Stored In A Hashtable?

Mar 25, 2009

I am new to VB.net and I am trying to work out an exercise from a book I am reading on VB. Basically I am storing some book information in a hashtable using a class called Book to store the book information. I am trying to work out my Search and Display All procedures. My Search will work for the first value in my arraylist but not for any other values. I even added the ISBN to my book class to try and use this as a search point. The ISBN is used to pull the item from the hashtable as well.

In the main code I am having problems with the ButtonSearch and ButtonAll.

[Code]...

View 9 Replies

Keeping Track Of Values In Different Forms?

Feb 10, 2011

I am trying to create a quiz application in Visual Basic 2008. I need to be able to store a score value when the player gets a correct answer. When the value is stored a new question set appears. Once the score is calculated I want to be able to show this is in a new form so the value needs to be passed from one form to the other. I'm not entirely sure how to do this but I believe it will incorporate a module.

View 9 Replies

Track Bar Changing Transparentcy Of Forms?

Mar 24, 2011

On my program I would like a track bar to change the Opacity of certain forms. There is a checked list box so if the user checked the main form and some other forms, boxes and used the track bar to change the Opacity of those forms. If the user uses the track bar and goes right it will increase the Opacity and to the left decreases the Opacity. Then when the user is all done He/She will press the Apply button to apply the changes of the Main Form or Forms.

View 11 Replies

Get A Hashtable Key Name From A Value?

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

Put A Hashtable In Another Hashtable?

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

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

How To Serialize A Hashtable

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

C# - What Is The Generic Version Of A Hashtable

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

Create Hashtable With Values?

Oct 12, 2010

Is it possible to create a hashtable "pre-populated" with values?[code]...

View 2 Replies

Hashtable Key Not Recognised In Collection?

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

Shared Hashtable Between Different Apps?

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

.net - Storing And Calculating Data Into Hashtable?

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

C# - Get Closest/next Match In .NET Hashtable (or Other Structure)?

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

C# - Sorting Hashtable By Order In Which It Was Created

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

Convert Argument Function In Hashtable?

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

Declaring Public Variables New Hashtable

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

Multi-client / Server App That Needs To Use A Hashtable

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

Printing Out Large And Complex HashTable?

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

Storing And Calculating Data Into Hashtable?

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

Bind HashTable Keys To A ListBox In Program?

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

Convert A String Of Key / Value Pairs To HashTable Or Dictionary Or?

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

Dictionary Or Hashtable And Iterating In Reverse Order?

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

Hashtable - Get String Representation Of Object Reference

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

Hashtable Value Array (late Binding) Error?

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

Import Hashtable's Fields In A Adodb Recordset?

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

Save HASHTABLE To Data Or Text File

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

VS 2008 : Storing And Calculating Data Into Hashtable?

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

VS 2008 Overriding Hashtable's Item(KEY) Property

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

VS 2010 Share A Hashtable In Multiple Threads?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved