Re: Checking if entry is already in List
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Thu, 19 May 2005 08:52:13 -0400
"Ken" <ken@xxxxxxxxxxx> wrote in message
news:uxEcjtGXFHA.3864@xxxxxxxxxxxxxxxxxxxxxxx
> Hi all!
>
> I'm looking for a fast method for adding items to a list, verifying if
> the item is already listed, in order to prevent doubles.
>
> Thanks a lot in advance for any ideas
You need to provide more information for any answer other than just a
general one. For example, is this "list" a ListBox or ListView or some
other control? Is it an array? A collection?
Generally, what you must do is loop through all the items and check yourself
to see if the item is already in the list. If the items happen to be in any
kind of collection (for example, the ListItems collection of a ListView
control), you can specify a key. Since keys must be unique, if an item with
the same key already exists, you'll get a trappable runtime error. This can
be a very effective way of preventing a duplicate from getting added to the
collection.
--
Mike
Microsoft MVP Visual Basic
.
- References:
- Checking if entry is already in List
- From: Ken
- Checking if entry is already in List
- Prev by Date: SQL Server Cursor and VB6
- Next by Date: Re: Same code, different outcomes
- Previous by thread: Re: Checking if entry is already in List
- Next by thread: RE: Checking if entry is already in List
- Index(es):
Relevant Pages
|