Re: Help with sorting an Arraylist that contains Structures

Tech-Archive recommends: Fix windows errors by optimizing your registry



Cool, I'll check it out. Thanks.


"Jack Jackson" <jjackson@xxxxxxxxxxxxxxxx> wrote in message news:c0jsa4hrrfchq8o584o27cule3p5d6gp6s@xxxxxxxxxx
The generic List(Of T) is in 2.0. Its advantage over ArrayList is
that the contents of the list is typed so you don't have to cast the
contents and therefore avoid runtime errors if you make a mistake
casting the contents. I also strongly urge you to use it instead of
ArrayList.

On Thu, 21 Aug 2008 20:48:26 -0700, "Justin" <None@xxxxxxxx> wrote:

First, until just now I never heard of "lists". However you mention VS2008
specifically and while I am using VS2008 I'm wanting to stay with in the
confines of framework 2. Does your suggestion do that? If so then I'll
read up on it.

Googling "VB.NET list" came up with nothing but arraylists and listboxes.

I already know arraylists and I already know how to check for dups before
adding so it was pretty simple to bang out the code. This arraylist is used
all over my app.



"Bill McCarthy" <Bill@xxxxxxxxxxxxx> wrote in message
news:127A8FEC-F7C3-4C20-A160-323A34539761@xxxxxxxxxxxxxxxx
Hi Justin,

First, why are you using ArrayList ? You should use the generic List, eg.

Dim myList as New List(Of TabStructure)

Then, assuming you are using VB 2008, you can pass in a lambda function to
the sort method:

myList.Sort(Function(x, y) x.TabName.CompareTo(y.TabName))







"Justin" <None@xxxxxxxx> wrote in message
news:OEUepa%23AJHA.1828@xxxxxxxxxxxxxxxxxxxxxxx
Ok, I give up. I can't seem to construct a decent (productive) way of
sorting my arraylist.

I have a structure of two elements:

Structure TabStructure
Dim TabName As String
Dim FullFilePath As String
End Structure

Then for example I:

Dim tab as New TabStructure

some code

Then I add "tab" to an arraylist.

At some point I loop through my arraylist, grab data and create tabs from
it. Of course the resulting list of tabs are out of sequence.

Can someone help me to sort my array list alphabetically by
TabStructure.TabName?

I would greatly appreciate it.

.



Relevant Pages

  • Re: Combobox not showing items
    ... I have written the small test (that contain 2 tab pages) for this issue ... combobox1 & combobox1 are placed in the separate ... > ArrayLists. ... When interrogated the boxes all have the correct items in its ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Help with sorting an Arraylist that contains Structures
    ... It uses generics, so the item type is strongly typed. ... I already know arraylists and I already know how to check for dups before adding so it was pretty simple to bang out the code. ... Dim myList as New List ... Dim tab as New TabStructure ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Help with sorting an Arraylist that contains Structures
    ... Googling "VB.NET list" came up with nothing but arraylists and listboxes. ... Dim myList as New List(Of TabStructure) ... Then I add "tab" to an arraylist. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Help with sorting an Arraylist that contains Structures
    ... Dim myList as New List(Of TabStructure) ... Dim FullFilePath As String ... Then I add "tab" to an arraylist. ...
    (microsoft.public.dotnet.languages.vb)
  • arraylist - childmdifrm.Activate - how?
    ... Dim frm As frmEdit = CType, ... So I get the position of the record on the grid from the ... But I am using 2 arraylists. ... >from the grid and then invoke a childmdi form. ...
    (microsoft.public.dotnet.languages.vb)