Solved

Sort order in Collections

Posted on 1998-08-20
1
138 Views
Last Modified: 2010-04-30
Are VB collections always sorted by key?
i.e. if I add items only using data and key (not after:= or before:=) will For Each ... enumerates items in order of keys?
In other words - I need the *sorted* list of items. May I just use collections for that purpose and be sure that it will work... ? If no - what may I use except sorted ListBox?
0
Comment
Question by:dksqrt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 50 total points
ID: 1430097
You can't use collections for that-they contain items in the exact order you added them. You you want sorted items, you can add them to listbox and collection at the same time, and set .ItemData of the list to the index of the same item in the collection, so you can refer to it later
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question