Algorithm - Combine Multiple Lists, Resulting In Unique List And Retaining Order

Apr 28, 2010

I want to combine multiple lists of items into a single list, retaining the overall order requirements. i.e.:

1: A C E
2: D E
3: B A D

result: B A C D E

above, starting with list 1, we have ACE, we then know that D must come before E, and from list 3, we know that B must come before A, and D must come after B and A.If there are conflicting orderings, the first ordering should be used. i.e.

1: A C E
2: B D E
3: F D B

result: A C F B D E 3 conflicts with 2 (B D vs D B), therefore requirements for 2 will be used.

If ordering requirements mean an item must come before or after another, it doesn't matter if it comes immediately before or after, or at the start or end of the list, as long as overall ordering is maintained.

This is being developed using VB.Net, so a LINQy solution (or any .Net solution) would be nice - otherwise pointers for an approach would be good.

Edit: Edited to make example 2 make sense (a last minute change had made it invalid)

View 1 Replies


ADVERTISEMENT

Sql - Asp.Net VB Or C# How To Combine Lines & Columns Based On Unique Primary Field

Mar 3, 2010

I have been working on a web based report from an existing client/server apps mssql database. I have a working query, that pulls this information together from many tables, and can provide the query and a result set if necessary.

The results currently are similar to this.

ID | Name1 | Date1 | Veh | PO | Stops
_________________________________________
1 | Bob 1 | 12/1 | Car | 1234 | 4
2 | Sam | 12/3 | Car2 | 2245 | 3
2 | Joe | 12/4 | Van1 | 5568 | 2

[Code]....

View 2 Replies

Linq - Merge And Order 2 Lists Of Different Objects?

Mar 15, 2012

I have collections of 2 different types - let's call them Cars and Trucks. Both share base class Vehicle, which has property Passengers.I want to merge them into a single collection ordered by that property. E.g., merge Cars and Trucks and order by Passengers.

View 2 Replies

Run The FindPath() Function 2000 Times, And Return The Resulting List Of Moves Into IntLists()(), My Jagged Array?

Mar 31, 2009

I'm working on a program dealing with jagged arrays.Code is below.The FindPath() function works perfectly.It essentially randomly chooses an action from 3 possible choices.The goal of this function is to make it to position (3,3) from (0,0).Sometimes it makes it, sometimes it doesn't.It gives up after 2000 moves.

The PushButton() function is where I have the problem.I want to run the FindPath() function 2000 times, and return the resulting list of moves into intLists()(), my jagged array.I want to use

intRuns = 0
For intRuns = 0 To intLists.GetUpperBound(0)
lstMoveList.Items.Add(intLists(intRuns).GetUpperBound(0)) 'here is where I get the problem.

this section of code to dump the number of attempts it took into a listbox on the main window.I do this at the bottom of the FindPath() function, but that is for testing purposes only.I eventually want to take the successful attempts and manipulate those, so eventually I get the minimum possible number of movements to get from the starting point of (0,0) to the ending point of (3,3).

Function PushButton()
Dim intRuns As Integer
Dim intLists(2000)() As Integer[code]...............

View 3 Replies

.net - How To Combine Multiple Lines Into One

Nov 4, 2010

I am trying to figure out a way of combining the below Dim statements into one line and maybe also combining Return dblResult into there. currently it is three lines and I have been told that it is possible but kind of lost of how to do it

[Code]...

View 3 Replies

Combine Multiple Files Into One?

Jan 11, 2010

How do I combine multiple files into the one file with a new extension. No need to be compressed. So I avoid Zip or similar solutions. (Actually don't want to add third party solutions into my application.)

View 13 Replies

Combine Multiple VB Arraylists Into One?

Sep 8, 2010

I have three arraylists (datasets and subsets) that I need to combine into one arrraylist so I can databind it to a repeater control and then present data to the user. As far as I know, you can only bind the repeater with one datasource (please correct me if this is wrong) that's why I'm combining these arraylists.Each arraylist has an ID from the database which I can use as a datakey to keep the data aligned. How do I combine these lists?

View 4 Replies

Combine Data From Multiple Tables?

May 12, 2009

I am used to creating a data set with data from one table, for instance:

[Code].....

Now I am needing to add a second table. For instance, my second table "EQUIPMENT" has a field called "DESCRIPTION" that I would like to add to my dataset. The "WORKORDER" table has a field called "EQNUM" which is what the "EQUIPMENT" table uses as the primary key. how to combine these into one dataset?

View 8 Replies

Combine Multiple DataTables In One DataTable?

Apr 6, 2012

I am using Microsoft Access database. Since Access Database Table cannot have more than 255 columns, I am using vertical database partition technique where I have splitted informations into 5 different tables. Each table has 100 columns, and first column is primary key. Now I need to read data from these five tables so that I can export it into Excel file.

[Code]...

View 2 Replies

How To Combine Multiple Matrices Into A Single One

Jan 12, 2011

I am trying to understand transformation matrices (not just their implementation in VB, but in general) and I've put about 3 full days into this so far. I believe I have the data in my matrices correct. Applying any single matrix to an array of points does a correct transformation.I am wondering if I understand how to combine multiple matrices into a single one.I understand you just have to multiply them together.I took this to mean you just have to multiply each element with its corresponding element in the second to make a third matrix?[code]

View 5 Replies

VS 2008 Combine Multiple Files Into 1

Sep 2, 2009

writing a script to allow the user form to browse to a directory and combine multiple files to one text file. In DOS it would be copy *.* to Text.txt.

I am using Visual Basic 2008 express...

I can use the OpenFileDialog to browse and open a single file but I am unable to use the multiselect option to open multiple files.

all files are parsed in the same place.

I have attached what I have managed so far which included converting the opened file to .txt

View 16 Replies

VS 2010 Combine Multiple SQL Queries?

Feb 13, 2012

My project contains a DataGridView with a SQL Database Table called Shows. This is a list of TV Shows and I want to apply several filters to it. So I have several different columns to apply the filter to.

1. Completed (bit)
2. Hide (bit)
3. Seen (bit)
4. Genre (nvarchar)

Currently I am using RadioButtons to switch between the queries, but I want to be able to have several filters applied at the same time with CheckBoxes.

[Code]...

View 4 Replies

Algorithm - Take A Database With Multiple Entries Of 11 Digit Number?

Jun 21, 2011

I am trying to take a database with multiple entries of 11 digit numbers and run a check sum algorithm that adds the 12th digit to the 11 digits as an output.The algorithm is as follows:

Add sum of odd digits starting with first digit, then multiply by 3.

Add sum of even digits, then add to result of odd digits multiplied by 3.

Take result and divide by 10. The remainder is the check sum which needs to be added to the end of the original 11 digits.

View 22 Replies

.net - Reference Elements In Multiple Lists Together?

Apr 14, 2012

For my first post I've got a tricky question. I'm past walking through tutorials but not far enough to join the Open Source Community.this Question I'm trying to create a program that tracks combinations used in Alchemy Games (Generally on a mobile phone etc)I've got the following classes

Class Game contains properties for Elements and Combinations
Class Elements Inherits List(Of Element)
Class Combinations Inherits List(Of Combination)
Class Element
Class Combination

Combination contains Element 1 and Element 2 and List(Of Element) for the results My Question: Using Game.Elements how can I add a readonly property for combinations of that element.

[Code]...

View 1 Replies

Handle Multiple Dropdown Lists In ASP.net?

Aug 16, 2011

One of my clients wants a set up multiple dropdown lists as a set of outbound links (yes, I cringed too, but he does have his reasons. there are 3 dropdowns, each one pertaining to its own group of links. When each dropdown has its SelectedIndexChanged, it then redirects based on the choice made. However, lets say I make a choice in the second dropdown. It goes to the proper link. If I then choose a link in the first dropdown, it goes to the proper link. Then if I select a link in the third dropdown, it will go to the link specified in the choice I made in the FIRST dropdown.

How can I code it so that it will always select the most recent selection?

View 3 Replies

Asp.net - Efficient Way To Combine Two List(Of String)?

Mar 16, 2010

Let's say I've got: Dim los1 as New List(Of String) los1.Add("Some value")

Dim los2 as New List(Of String) los2.Add("More values")

What would be the most efficient way to combine the two into a single List(Of String)?

Edit: While I love the solutions everyone has provided, I probably should have also mentioned I'm stuck using the .NET 2.0 framework.

View 4 Replies

VS 2005 Sort List Of Objects By Child List Order?

Jul 20, 2011

I'm having a bit of a 'brain doner' moment here

I have a list of Objects. Each of these Objects contains a list of other Objects (pseudo code) :-

Private Structure Object1
dim Name as string
dim ListOfObject2 as List(Of Object2)

[Code]....

I need to sort the list of Object1 by the Value in Object2. I have a comparison class which sorts Object2 by its Value nicely.

View 13 Replies

Auto-complete Combobox From Multiple Lists

May 19, 2009

I have a small HR app.First step for user is to select the employee.I wanted a single combobox (autocomplete , drop-down), where the user can start typing either firstname lastname or nickname (these are 3 different fields in an SQL DB).At first, I would have the user check a checkbox near the combobox to select what they would be searching by (first, last, nick name), but then I thought - someone could probably help me with an example of not having to select which name type they are searching for, but just start typing and the combobox would autocomplete based on whichever name ?

View 3 Replies

Populate A DataGridView From Multiple Lists Without Iterating Through Them?

Jun 30, 2011

Say I have three lists containing multiple objects. Lets also assume they each contain the same number of items. [code]...

Now say I have a dataGridView that I have defined as having three columns. Is there a way to assign the contents of each of the lists to each of the three columns (e.g. column 1 = myList1, column 2 = myList2, etc.) without iterating through each of the lists? I know I could define a dataTable, create the columns, and iterate through each of the lists...then associate the dataTable to the dataGridView's dataSource. However, I don't want to iterate through the lists since in my real application, these lists are large and the iteration would take too long. I'm just wondering how to assign these lists to a column in a dataTable in bulk.

View 2 Replies

Selecting Items At Same Index In Multiple Lists?

Apr 6, 2012

I am working on a project for software engineering where we are trying to create a warehouse inventory system. I have created an inventory page where I can add/delete/search for an item as well as access invoices and reorder items... i am struggling on the delete item part. I have my design set up where there are four different lists on my page. One for name, one for serial number, one for RFID number and one for amount in stock. I want to be able to select an item by name and its information in serial number, rfid, and amount also select and have no idea how to go about this..I wanted to use four different lists because I need to be able to delete an item from the list and it remove just one from that stock and not the entire item unless there is only one of that item left in stock.

for my inventory page

Public Class InventoryDepartment
Private Sub InventoryDepartment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]....

View 14 Replies

Combine Multiple Files Into An Existing Excel Sheet?

Jan 19, 2012

I've programmed a vb.net application. This is a matching applcation generates 3 lisboxes. I have written these to a csv files. [code]...

View 3 Replies

How To Combine Multiple Text Files In Specific Directory

Sep 11, 2009

How can I combine multiple *.txt files in a specific directory into one txt file in another directory using VB.NET? (And to delete blank lines at the end of the new file)

I know how to do it in vbscript:
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFSO.CreateTextFile("C:logsimportoutput.txt")
[Code] .....

View 3 Replies

Retrieve A List From Sharepoint Using Lists() Web Services?

Jun 12, 2012

So I've been trying to retrieve a list from sharepoint using Lists() web services and then displaying the list on a datagrid. However I am having some weird problem. My code so far is

'Declare and initialize Lists Web service.
Dim listService As New Lists()
'Authenticate
listService.Credentials = System.Net.CredentialCache.DefaultCredentials

[Code]...

1) It also displays a column called "ows_owsHiddenversion" which I have no idea where it's coming from.2) The order of the columns that are displayed are different from the order in the sharepoint site.3) I have a column called "DONE?" and it is a choice type with the options of choosing 'Yes' or 'No'. But for some reason, in the datagrid, the column under DONE is all blank and I cant figure out why all the 'Yes's and 'No's are not showing up. All the other values for the other columns appear fine.4) I am sorting the data from the sharepoint list by the "Division" column which is fine but the header of the column in the datagrid is labeled "Title". I checked the XmlNode outer and inner xml and for some reason the Field Ref is set to "Title" to represent the "Division" column

View 2 Replies

Forms :: Retaining Data Across Multiple Forms

Sep 8, 2010

VB.NET newbie here... I have an vb.net windows application set up. It has multiple forms, about 6 in all. There's a main menu form, and then 5 other forms to collect data. The user will collect data on each form and bounce back and forth between forms. How do I get the forms to retain the data that has been entered into the text boxes and/or other controls on the forms? For example, they might fill out a few textboxes on a form, but then need to go to a different form and fill something out... and then back to the previous form. Right now, when they come back to the form, all the data previously entered in to the text boxes is gone.

View 1 Replies

VS 2010 - Multiple ComboBoxes And Dropdown Lists With Different Items

Jul 16, 2010

I have multiple combox boxes,
A B C
Combobox B has items Fruit, Veg, Dairy
Combobox C needs to contain 3 list and depending on what value is selected in Combo Box B.

For example,
If I select Veg in Combo Box B, I would like to have a drop down list containing "tomatoes, lettuce, onion,..........."
If I select Dairy in Combo Box B, I would like to have a drop down list containing "Milk, Cheese...................."

View 8 Replies

Adding A Delimiter - Combine Multiple Files Into One Single File

Jan 24, 2012

I've made a rudimentary program that combines multiple files into one single file. Currently if I combine two .csv files together the output comes out correctly for what I need, which is a coma delimited file. When I try to combine two .csv files into a .xls file it doesn't format correctly (I get all the data separated by commas, but thrown into one column in the .xls file). For this reason I believe I need to add a delimiter.I'll post my code below.

[Code]...

View 11 Replies

Multiple Unique Textboxes

Jan 6, 2009

I have a form on a program i am working on that i need to check if all the textboxes hold a separate value when a button is clicked. I know that i can use comparative operators to check the values are different, but i am using 6 different textboxes, and don't fancy typing. [Code] 36 times over, could somebody point me in the right direction for an easy way of checking that 6 textboxes hold different values. Also, as a sidenote, i would like to know if there is a way to check if all 6 are numeric in an easier way than typing is-numeric(textbox1).

View 10 Replies

Unique Items In A List

Nov 7, 2010

I am new to VB.NET 2008 and a few users on this forum have suggested using Generic Lists instead of the old VB6 model of Collections. I need to add to the list of several items to the list, but what is happening it it is changing the first item in the list when I add the second, so there are now of the same item in the list. How do I add unique items to the list? Also, in the collection world, I could define a index of an item by placing the index value into second item of the Add Function.

[Code]...

View 3 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

Identify Unique Records Between Two List (of T)?

Nov 9, 2011

I have 2 List (of T) populated with the following

Dim curweekFolder As String
curweekFolder = String.Concat("c:", curweek_date.SelectedItem)
Dim preweekFolder As String
preweekFolder = String.Concat("c:", preweek_date.SelectedItem)

[code]....

I first wanted to identify which files matched in filename and list those in ListBox1, the following that was suggested on this forum worked very well (I added the minus last 19 characters as they would be different).

ListBox1.Items.AddRange(curlist.Where(Function(fi) prelist.Any(Function(fi2) fi.Name.Length - 19 = fi2.Name.Length - 19 AndAlso fi.LastWriteTime = fi2.LastWriteTime AndAlso fi.Length = fi2.Length)).ToArray)Now I need to populate ListBox2 with the files that do not match in each List (of T), again without looking at the last 19 characters. So for example if the first List (of T) had A.txt, B.txt and C.txt and the second List (of T) had A.txt and B.txt then ListBox1 would have A.txt and B.txt while ListBox2 would have C.txt.

View 1 Replies







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