Arrays - Compare Two Lists 2D And Determine

May 2, 2012

I declare my 2D lists:

Dim _invoiceitems As New List(Of List(Of String))
Dim _dbitems As New List(Of List(Of String))

Each List is filled like this: Example Code To fill:

_invoiceitems.Add(New List(Of String))
_invoiceitems(0).Add("Code #")
_invoiceitems(0).Add("Quantity")

Well, now i need a third list called (_changesitems) Note that this result with the differences: be the result of subtraction of quantities if this is found (dbitems - invoiceitems).

View 1 Replies


ADVERTISEMENT

.net - Compare Different Generic Lists?

Mar 2, 2011

I have a method where I'm taking a generic object and using TypeOf to check what has been passed through. Now I would like to pass it a List(Of T) (T being anything) and no matter what T is I'd like to do the same thing to this list. I tried the following:

public sub foo(ByVal obj As Object)
if TypeOf obj Is List(Of Object) Then
'do stuff
end if
end sub

but this doesn't seem to work if I pass it List(Of String), say. I suppose that List(Of Object) and List(Of String) are being treated as different objects, but I thought that since String is an object, the comparision might work.

Now I realise that this is as ugly as sin and I'm better off overloading the method to take List(Of T) as its parameter, but I'm mostly asking out of curiosity: is there a way of comparing the types List(Of Object1) and List(Of Object2) and getting a positive result, since they are both just List(Of T)?

View 3 Replies

Compare Differences Between Lists?

Feb 17, 2011

Compare differences between lists?I have two sets of lists below[code]...

View 1 Replies

[2005] How To Compare Two Lists

Jan 22, 2009

Im trying to compare two lists,to find out how which items occur in both lists. I also want to test for duplication within a list.Now, the obvious way is a loop/compare which works fine for a low number of items. Beyond 10000 items, things slow down much more than a factor of 10.

Dim List1 As New List(Of String)
Dim List2 As New List(Of String)
Dim List3 As New List(Of String)

[code]....

View 3 Replies

C# - .NET Generics - Compare Two Lists And Filter?

Jun 19, 2011

I have two generic lists of type T. Both lists contain same type, and I'd like to create a third list (or a filtered version of list 2) based on the items in list two that do not exist in List 1, based on the ID of each item.Each list holds a "Package" object, which has an ID property.Right now I mocked up the code using For Each loops, which I know is horrible (the Big O is constant time) so I'd like a more efficent method. this code is in VB per project requirments, but I prefer C# - so either code sample would work for me.

Private Sub RemoveStockPackagesFromSelection()
Dim p As Package
Dim packageList As List(Of Package) = New List(Of Package)

[code]....

View 5 Replies

Use Arrays Or Lists When Sorting?

Jun 24, 2011

I have been assigned a program for homework in which I need to take in information about songs from a text file and then be able to sort the list alphabetically, by genre and by length. I also need to be able to filter it by genre. The user can then move songs they choose from the master list to a playlist where again the list can be sorted by either genre or play order.My book only covered sorting array when they are one dimensional however I need to be able to sort a multidimensional array by different columns. I asked my teacher but she had so much going on that we didn't really have time to get into it, so I decided to ask here.

I'm not looking for code, just to get pointed in the right direction. For instance rather than using a multidimensional array would it be better to pull the values in and then put them into an array of song objects with properties for each value? And if I choose to go that route is an array the best structure to use? I have to use an array of some type, but the problem says nothing about whether or not it can be a list or other array type structure.

View 6 Replies

Arrays / Lists And Computing HashValues

Jun 13, 2010

I've had experience with using hashvalues from String objects. E.g., if I have StringA and StringB both equal to "foo", they'll both compute out the same hashvalue, because they're set to equal values. Now what if I have a List, with T being a native data type. If I tried to compute the hashvalue of ListA and ListB, assuming that they'd both be the same size and contain the same information, wouldn't they have equal hashvalues as well?

Assuming as sample dataset of 'byte' with a length of 5
{5,2,0,1,3}

View 3 Replies

Matching 2 Variables With Arrays Or Lists To Get 3rd Value?

Nov 11, 2011

I have a pipe delimited file with 3 values on each line, something like this:
0001|234587|Bracket, 3 x 3 x 0.125, Steel
0001|254378|Bracket, 4 x 4 x 0.125, Steel
0003|234587|Hinge, 4 x 4 x 0.125, Brass

The first Value can be duplicated in the file, the second value also can be duplicated. There are no instances of BOTH values duplicated on 2 or more lines. I need to read another file and get the first 2 values, then look up those two on one line to get the proper 3rd value. The "other" file looks a bit like this:
0E0522070001EF54ED7823458700FF00FFA5A5A5A5
-----------XXXX-----------XXXXXX--------------------- (X's are the data, the rest is filler to comply with some code unknown to me)

Right now I have code to read all into an array (split on vbcrlf), then split each line on "|" and populate three arrays, I then go thru every element of the first column that matches the value I am looking for and test that the second column also matches the second value and if so, return the third array contents at the same index. This seems crude and inefficient. Cannot use a hashtable (I don't think) as it only supports 2 values. A List(Of) doesn't seem to work either and I don't want to use a database.

View 6 Replies

.net - Find Common Values In Several Arrays Or Lists

Dec 23, 2011

Find common values in multiple arrays with PHP Pretty much does what I need, but in PHP, I need VB. My situation is I am trying to create an intelligent stock pick system based on multiple stock locations. At the point of invoicing, we loop through the items invoiced and check the stock database for available stock.

If all items on the invoice are available to pick from stock location 1, then all should be picked from stock location 1... etc. If all most items are available from stock location 1 except one or two, then pick all stock from stock location 1 except for the exceptions which should be picked from the location with the highest available stock. Finding highest available stock is simple, but I can't work out how to analyse the stock availability from multiple locations and finding the common stock locations.

[Code]...

View 2 Replies

How To Create A Popup Dialog With Lists Of Arrays

Mar 17, 2010

I was wondering how you create a form with three lists. Each list representing a different array.

I guess the question is how do you take an array and make it into a list so it shows up on a list box?

View 2 Replies

VS 2010 Binary Search Of Arrays/Lists?

Dec 15, 2011

my binary search isnt working, i think it has to do with the fact that im using a list and its searching thru an array

List
Option Strict On
Public Class Form1

[Code].....

View 9 Replies

Join Lists Or Arrays Like Outer Joining Tables In SQL?

Jun 27, 2011

Basically what I'm having to do is create a program that takes a list of CaseIDs and compares them to a table on a remote SQL server. However, the table holding the CaseIDs on the remote server has nearly 120,000 records.

Currently my plan is to query all records on the remote server, save the query and the current list to tables in an Access DB file and then run an outer join to see which CaseIDs have no matching records on the remote server.

I believe this will be a much slower process than I would like. If I could load both queries into arrays or lists in VB and then compare them (therefore, not having to write 120,000 records to a DB file), it would be much faster.

View 10 Replies

VS 2008 - Are Arrays Considered A Type Of Collection Like Lists

Mar 2, 2010

Ever since I started using VB.Net I have been using the Generic List collection List(Of <Type>). Arrays, I haven't used so much. I used them a lot more when I wrote C code years ago.

1.) Are arrays considered a type of collection like Lists, Dictionary, Queue etc are? Or are they in their own category.

2.) Can I iterate over an array with a For Each loop like I can with other collections or do I stick with the normal For loop for arrays?

3.) There are certain methods that return arrays. Can I set a list object to hold this return value instead of an array?

View 6 Replies

Comparison - 4 String Lists - Compare The Contents Of The Input List - Containing Words

May 31, 2009

I have 4 string lists as follows

Dim input_list As New List(Of String) Dim input_POS As New List(Of String) Dim trigger_list As New List(Of String) Dim trigger_POS As New List(Of String)

I want to compare the contents of the input list (containing words (e.g., want, the) etc. to the ones of the trigger list (containign again words) and if a same entry (i.e. word) get the POS for both input word and trigger word from the relevant lists and put them into a property list. For example

input list (want, the, right)trigger list(want, there, wait)input list POS (verb, article, adjective)trigger list POS (verb, pronoun, verb)

Output property list (want:verb, want:verb) (only want is common between input and trigger list). Then I need to conduct a test between the two property items for similarites. If they are exactly the same, the code should output a confirmation "i.e., Yes" into a textbox. If not the code should output a "No" plus the contents of the property list into a textbox.

View 6 Replies

Compare 2 String Variables To Determine If They Are The Same?

May 23, 2009

how do i compare 2 string variables to determine if they are the same?ie:

if(string1 = string2 AND string3= string 4) then
perform operation
else
perform another operation
end if

View 2 Replies

Compare 2 Arrays Without Looping?

Nov 29, 2011

Is it possible to compare 2 arrays without looping? For this example, I need to compare aryFi.Count to currentarraycount. if aryFI.count>currentarraycount, then I need to add the ones in aryFi.count into a public array named pgarraylist. Since aryFi contains more items, I can't just take the .count-the difference in counts, I need a way to get the items contained in aryFi but not in currentarraycount. EDIT - currentarray is the list of currentarraycount Sounds confusing - but here's an example.

Public pgarraylist As New ArrayList
Dim aryFi As IO.FileInfo() = di.GetFiles("*.xls")
cntdif = aryFi.Count - currentarraycount 'currentarraycount is updated after changes occur and when loading program.
For y = cntdif To 1 Step -1

[code]....

View 2 Replies

Compare Two Arrays, Bytes?

Aug 13, 2009

How can i compare two arrays like :

Dim Ar1,Ar2 as array
Ar1 = My.Computer.FileSystem.ReadAllBytes("C:Try.mp3")
Ar2 = My.Computer.FileSystem.ReadAllBytes("C:Try1.mp3")

how can i compare that two?

View 6 Replies

Compare Two Byte Arrays?

Mar 9, 2009

I am trying to compare two long bytearrays in vb.net and have run into a snag. Comparing two 50 meg files takes almost two mins so I'm clearly doing something wrong. I'm on an x64 machine with tons of memory so there are no issues there. Here is the code that I'm using at the moment and would like to change.[code]...

View 5 Replies

Intelligently Compare Arrays With .NET 2.0?

Dec 28, 2011

I am trying to make an intelligent stock pick/dispatch location system at the point of invoice from a stock database. Multiple locations are available to dispatch from, and essentially I want to make efficient dispatch, so if all items purchased can be dispatched from one location, they are grouped and dispatched as such, but if not, it groups what it can and dispatches the rest from wherever the highest stock level is available.Because the number of locations has to be variable, this system is scalable.Because the number of items is also scalable So, instead of listing suitable stock locations, I am now listing the quantity of stock available in each location for the respective items.

Items Locations
_________|__1___|___2__|__3__| - this is location IDs
Item 1 | 3 , 4 , 1 - this is the qty of stock available

[code]....

I can turn this into a string which might be used to split and create arrays

ie
stockDetails = "3,4,1|2,4,0|1,3,1|6,1,3"

Here, the comma separated values are quantity of available stock in each stock location and the pipes separate the individual items, so the table above is translated to the string above.I am not keen on multi-dimensional arrays and don't know how I'd create one without knowing how many stock locations there are.

We can safely assume That the stock quantities are in the correct order to correlate back to the stock locations IDs.
Each pipe separate series of comma separated values will have the same number of comma separated values.I just can't work out how to determine the pick locations! In the above example, all four items can actually be picked from stock location 1, providing only one of each item is purchased. Suppose though a customer bought 2 of item 3. Then the pick would have to be from location 2. All kinds of other scenarios can of course be presented depending on the number of items purchased, the quantity of items purchased and how many stock locations there are to pick from.I started off simply picking from the location with the highest available stock, but that made no sense when stock was available to pick from more than one locaton because we ended up with multiple dispatch locations which was not necessary.How can I analyse these variable length strings/arrays to determine the most intelligent way to dispatch.

View 2 Replies

VS 2010 How To Compare Arrays

Jun 12, 2012

I'm trying to determine the highest customers in a single month of the year. I also need to add the corresponding month to that.

View 4 Replies

Inheritance And Variety Of Data Structures Including Queues, Lists, Arrays, Or Stacks In A Windows Forms Application

Jun 27, 2012

I'd like to give a homework assignment to a person learning VB.NET. I'd like it to use basic inheritance and a variety of data structures including queues, lists, arrays, or stacks in a windows forms application. I was thinking of a pizza-ordering application. This would allow them to utilize some basic inheritance and practice using .NET UI elements.

View 2 Replies

C# - Compare/sort Items From Two Arrays?

Jul 16, 2009

I have a question about efficient implementation. Lets say I have two arrays:

One array is all possible items in a house: Table, Chair, TV, Fireplace, Bed

The other is an array of items in a particular house: Table, TV, Bed

I also have two list boxes:

1. listbox for items in the house - the "HAS" list box
2. listbox items not in the house - the "NEEDS" list box

I need to list the items already in the house in the "HAS" list box as well as the items that are NOT in the house in the "NEEDS" list box. It seems to me that nested "For each" loops would be a start to solving this problem but I am not exactly sure which case needs to be nested.

View 2 Replies

VS 2010 Two Separate Arrays And Then Compare Them?

Jul 2, 2011

I want to put the matches from a regular expression into an array or something that i can use to compare it with another array, it being the lines from a txt file names "users.txt". Code A:

[Code]...

And the second code will do the exact same thing. What i want to do is compare each line in the Txt file (Code B) to the reg expression matches (Code A) and for it to alert me if any is missing. So it needs to compare Code B to Code A. (PS. Order is irrelevant, it can be in different places as long as its there) In my other thread i got a little confused and couldn't clearly communicate what i was trying to do.

View 32 Replies

Compare Arrays And Listboxes Values In VB 2010

Jul 22, 2011

I have a program that has to store a pre-made array that contains strings (moviename, moviegenre).

I setup all the items in the array already, example:

moviearray(0,0) = "Green Lantern"
moviearray(0,1) = "Action"

For this example, if the user selected "Green Lantern" from my listbox, then the label needs to display "Action". So yeah, it's a 2-column array: first column = movie name, 2nd column = movie genre. Now, I have a listbox containing all of the movie names (not entered by the array, but entered through the Item property of the listbox). When a selection is made in the listbox and a button is clicked, I need to have the genre of the movie output to a label. That is where I am stuck, I just can't figure out to compare what's in the list box with the first column of the array to output the 2nd column to the label.

View 15 Replies

Compare Two Arrays And Remove Matched Item?

Jan 13, 2010

i have tese two arrays

if i find filter_ids in stroutids i want to remove those from stroutids array
Dim strOutIDs() As String = Split(OutIDs, ",")
Dim Filter_Ids() As String = Split(Me.ucIo_Entry.Filterd_RowIds, ",")

[Code]...

View 2 Replies

Forms :: Arrays And Radio Buttons - Determine Which Button Is Selected And Assign It To A Variable

May 15, 2009

I am having 3 radio buttons and a button The codes should be added to the button_click event, when ever the radio button is selected and the button is click then, The codes should determine which button is selected and assign it to a variable. Create a two parallel 1-dim arrays and populate it with the data below:

[Code]...

View 10 Replies

Sorting 2 Lists Based On Only One Of The Lists?

Apr 1, 2011

I have two lists. One list is a list of names, the other list is a list of how many times each name is found in the first list noted in the database

so...
Nick
John
Jim
Jack

is the firs tlist

10
13
13
2

is the second list. Nick had 10, john 13 and so on.I want to sort the second list from large to small, but have the index for the first list still linked to the correct amount of calls.i do it this way so I can

for x = 0 to num_of_names
string = lst_name(x) & "-" & lst_count(x)
next x

View 3 Replies

Know If An Array Of Lists Contains Similar Items (similar Lists)?

May 20, 2010

I know how to check whether an item exists in a list using (MyList.Contains), But I do not know how to check the whole list. For example (use one button and one richtextbox):

[Code]...

View 14 Replies

Compare Date - Compare Textbox1 And Textbox2 Text

Mar 3, 2010

I have two textbox in my application.

Textbox1.Text="19-Jan-2010"

Textbox2.Text="Jan 2010"

May I know how can I compare that Textbox1 and Textbox2 text is within same month and same year?

View 1 Replies

VB6 Used Recordsetsor Arrays - .Net Framework In VB2010. Datasets, Dataviews. Tableadapters, Arrays. Enums ?

May 9, 2010

In VB6 I load a recordset containg all of the records (6 fields per record)in a table into an XArray and then manipulate the records in the array and then write them back to the original table. The array issorted by the first field (1 to maybe 8000 or more) I need to find records in the array by an ID field and then move them (because of some external criteria that happens many times) from say number 400 to number 375. Then all of the other records between 375 and 399 were renumbered up 1 to fill the gaps left by the move.

The XArray worked well as it could find and also move to a next record easily to facilitate the revisions to each record quickly. Everything is done in VB6 in code and nothing visual needs to be shown to the user until say 2000 of these external changes are complete. What is the best, most efficient way to do this in the .Net framework in VB2010. Datasets, Dataviews. tableadapters, arrays. enums ?

View 3 Replies







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