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


ADVERTISEMENT

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

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

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

Sorting Arrays In .net?

Aug 10, 2009

I need to know if there is any simple way to sort an array in visual Basic.net. I have been trying for some time without any real reliable results or wierd results. Here is the code this is the sort routine which transfers a csv text file read earlier into an array.

Private Sub btnSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSort.Click
Dim i As Integer = 2 'inner loop
Dim j As Integer 'outer loop
Dim tempstore As String = String.Empty
ProgressSort.Minimum = 0

[Code]...

The data seems to be read into the array but the sorting takes a very long time and I am not sure if it is working or not. I have read from other forums that it is easier to sort the array read from csv before splitting it. This record I am trying to sort is 250 records long. I have no idea how long that should take. Not even sure if the algorithm I chose is correct.

View 5 Replies

Creating Copies Of Arrays And Sorting?

Mar 17, 2010

Basically the assignment says:Create an array that accepts user input. When the user inputs -1, stop the entering process.Check user input to circumvent bad numbers (numbers less than -1)Make two copies of the array (making sure the two new arrays are only as big as the amount of numbers the user input, might need a counter)Sort the first copy using any algorithmSort the second copy using standard array.sort method.Display all three arrays in a form.I have this so far, and I'm stumped as to where to go next.

asdf
Public Class SortingForm
Establishing Module-Level Variables

[code]....

View 2 Replies

VS 2005 Sorting Parallel Arrays

Jan 4, 2012

In Visual Basic 2005 is it possible to parallel sort three or maybe four arrays? I have a function that is trying to accomplish this but it only parallel sorts the second array with the Array that it is being sorted with. Here is the code

Sub ParallelListBoxSort(ByVal byList As ListBox, ByVal otherLists() As ListBox)
Dim ii As Integer = 0
Dim a As Integer = otherLists.Length

[Code]....

'listToArray' is just a function that converts a list to an 1-Dimensional array and 'setArrayToListCollection' just puts the array back into the appropriated list.

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

Sorting Arrays Numerically / Alphabetically In Textbox

Feb 26, 2011

In Visual Basic 2008 or 2010. How to sort numerically in this format:

From this:
"basketball" 900,000
"golf" 300,000
"bike" 600,000
"snow boarding" 800,000
"mountain climbing" 500,000
"roller blading" 100,000
"soccer shoes" 400,000
"football team" 700,000
"field track" 200,000

To this numerically:
"roller blading" 100,000
"field track" 200,000
"golf" 300,000
"soccer shoes" 400,000
"mountain climbing" 500,000
"bike" 600,000
"football team" 700,000
"snow boarding" 800,000
"basketball" 900,000

I would like to have a form application that I can drag n drop the words with their numbers into a Textbox1.text and have the Textbox1.text do the sorting.

View 1 Replies

Raise Events - Generic Function For Sorting Integer Arrays

Aug 26, 2010

I am very confuse over a Raise Events example and using delegate as a function pointer: I am clear with this function pointer example program below which creates a generic sort function for sorting integer arrays without changing the main sort function.
' Returns True if need to swap
Delegate Function CompareFunc(ByVal x As Integer, _
ByVal y As Integer) _
As Boolean

Here are two alternative target methods for the delegate - one for an ascending sort and one for a descending sort:
Function SortAscending(ByVal x As Integer, ByVal y As Integer) As Boolean
If y < x Then
SortAscending = True
End If
End Function
Function SortDescending(ByVal x As Integer, _
ByVal y As Integer) As Boolean
[Code] .....

View 1 Replies

Sorting Arrays Numerically And Alphabetically (like Windows Explorer) Without Using StrCmpLogicalW Or Shlwapi.dll - ASP.NET?

Nov 12, 2010

I created a sorter that StrCmpLogicalW / shlwapi.dll. unfortunately it causes errors on partial trust environments. I am in a really bad need of a solution that does not use 'shlwapi.dll' or StrCmpLogicalW and works in the same fashion.

Here's the sorter that causes the error.

Public Class nvSorter
Implements IComparer(Of String)
Declare Unicode Function StrCmpLogicalW Lib "shlwapi.dll" ( _
ByVal s1 As String, _

[code]....

View 1 Replies

Sorting 2 Arrays Side By Side?

Jan 18, 2012

Basicly I have a program that retrieves data and parses it, which is fine, so it starts from:11:981.8 which equals to November 981.8 now what I have done is split the "November" and the "981.8" into 2 different arrays, with other similar data, now what I need to be able to do, is sort the array in either Ascending or Descending order, however keeping in tact, the November and 981.8 side by side in a list box.

My current code is:

Private Sub sortData(ByVal strYear As String, ByVal strSort As String)
lbDispData.Items.Clear()
Dim strData As String = My.Settings.usage2011
Dim arrRawData() As String

[Code]...

EDIT: Just to mention, there are many more values, not just November and 981.8, there would be for example December and 128.1, January and 191.1, etc.

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

Excel Sorting Is Only Sorting One Column Not Multiple?

Mar 12, 2012

I'm having my program sort an excel sheet by a few columns. However, it is only sorting by the first column not the rest that I specify.ere is my sort code below:

myRange.Sort(Key1:=myRange.Range("A:A"), Order1:=XlSortOrder.xlAscending, Key2:=myRange.Range("G:G"), Order2:=XlSortOrder.xlAscending, Header:=XlYesNoGuess.xlYes, Orientation:=XlSortOrientation.xlSortColumns)

[code]...

View 1 Replies

Wpf - Sorting Observable Collection Incorrectly Sorting?

Aug 20, 2011

I have a WPF ObservableCollection which is bound to a ListBox and I have a Sort() method which when called will convert the ObservableCollection to a List(Of T), and undertakes a sort based on a date/time column within the collection.

The data is sorted, even when new items are added to the ObservableCollection, however the date/time isn't being correctly sorted. The data is sorting based on the date however it is very much random when it comes to the time portion. The following is an example of the outcomes I am experiencing:

[Code]...

Is there anything that I am doing incorrectly in this method that would cause the time portion not be included in the sort? Is there a better way of doing a sort?

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

Integer Arrays - User Enter In Big Integers Using - Two Parallel Arrays

Dec 10, 2009

My assignment is to have a user enter in big integers using what i think is two parallel arrays. I got this far but now im stuck. I think i need to actually convert the text box input into an array but i do not know how to do that. I am all over the place in this project.

'Created/ Revised by: Jessica Falcetta
'Cap 204 Final Project: Big Integer Project
'Project Purpose: To calculate large integers through parallel arrays

[CODE]...

View 5 Replies

Passing Arrays Through Fortran Dll From App Turning To Single Element Arrays?

Feb 2, 2010

I have a VB.net console app and I am opening a function in a dll written in fortran. I am passing 3 arrays through the function by reference. When they come back out the otherside they ahve all tunred to arrays of only one element And that element is 0.I read on the internet somewhere that when doing this kind of thing it is a good idea to only pass the first element of the array into the function.I tried changing my function declaration to accepting single elements rather than single dimensional arrays, and now the arrays are the same length before and after the function call, but they don't seem to be changing at all, so i'm not sure that this is working

View 1 Replies

VS 2008 Arrays Displaying States/searching Arrays?

Oct 30, 2010

the statement Dim state(49) As String and maintain a list of certain states. The list of states should always be in alphabetical order and occupy consecutive elements of the array. The buttons in the program should give the user the following options: (a) Take the state specified by the user in a text box and insert it into its proper position in the array. If the state is already in the array, so report. (b) Take the state specified by the user in a text box and delete it from the array. If the state is not in the array, so report. (c) Display the states in the array. "

Private Sub states_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
state(0) = "Alabama"

[code]....

View 1 Replies

Comparing Arrays :: Possible Without Iterating The Arrays?

May 3, 2010

I was wondering if anyone knows a built in method ( LINQ say or a LAMBDA expression or other way ) that you can compare2 arrays - collections that would be valid for an equivalent 3rd array - collection which is a combination of the 1st two.

As an example consider;
* * *
A L E

[code].....

View 17 Replies

Sort Three Arrays (the Other Two Arrays Are In Sync With The First)?

Oct 13, 2009

How can I sort three arrays so they are sorted together (the other two arrays are in sync with the first)?unsorted unsorted unsortedarray1]CODE]....

View 9 Replies

For Each Loop - Two Lists?

Jul 24, 2010

I would like to loop through two lists using a For each loop.
dim data as list(of pointpairlist)
For each recLine in records
For Each chan In recLine.channels and d in data
d.add( func(chan) )
Next
next

Note: each record line has one sample from each channel recorded. i.e. each record line is a slice of a 32 sensor recordings. I want to build up a x,y list of data points for each channel (the x axis is common to all channels). Is there some way to do it similar to what I have above (avoiding indexing variables).

View 2 Replies

Passing Lists From WCF To WCF In VB?

May 13, 2011

I'm trying to populate one list from another. I would think this code should work, but at the end of the day I get a list of identical items.

Public Sub WriteDatFile(ByRef lstReasons As System.Collections.Generic.List(Of LetterReason))
Dim tmplstReason As New TCPService.LetterReason

[Code]....

View 2 Replies

VB Lists And Calculations?

Jun 6, 2011

I'm very new to programing and am having problems trying to perform some calculations with a list. I have read in an array into a list with a count attached to each item example: "xxxxxx(intcount)". What I'm trying to do it use two xxxxxx(intcount)'s at xxxxxx(intcount+5) and xxxxxx(intcount+25) and use these two variables to calculate yyyyyy(intcount) but it isn't working. I understand this may be a stupid question but could someone please point me in the right direction.

View 6 Replies







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