o
k
q
u
e
s
t
i
o
n
s
.
c
o
m

Remove an Item from a collection -

Hi there. I'd really appreciate some help on this. I am checking an arraylist for a value in a collection. If the value is not present then I want to remove the item from the collection. This is the code I am using:

'Check each item against the ArrayList - if not there then remove from collection.
For Each Item In Purchase.items
If ArrayList.BinarySearch(Item.item_Code, New CaseInsensitiveComparer()) < 0 Then
Purchase.items.Remove(Item)
End If
Next

But this code throws an error once I remove an Item from Purchase.Items
How can I fix this and still keep this code nice and tidy?

Thanks.

 

[2008] Removing items from collection without shifting index -
Hi I have an old school collection that now I need a feature where I can remove an item, however the index can not change, it is very important, so how, if it's even possible can I remove an item but somehow keep the collection from shifting indexes? I tried setting all the elements


Error in Collection whenever delete one item from collection!!! -
Hii everybody, I am trying to remove one of the item from the collection, any item not like first or last or in sequence. LIke i have collection of 4 items and i removed 2 second item. After that i am trying to add new with new Key value whcih for this example is 5(In sequence). The


Remove an Item from a collection -
Hi there. I'd really appreciate some help on this. I am checking an arraylist for a value in a collection. If the value is not present then I want to remove the item from the collection. This is the code I am using: 'Check each item against the ArrayList - if not there then remove f


how to maintian index in collection class -
Hii To all, I have developed collection class that inherites System.Collections.CollectionBase class and used it to store objects of specific class. This collection class is attached with array of win forms. Collection idex is mtch with winforms array index. In each form activa


Removing items from a listview -
I have a listview that holds the title, Firstname, surname and Age of a peron object. The user is prompted to enter their details and select add, when add is selected the p object uses the add method to add a new p object to the mcolPersonCollection collection, it also simultaneously a


Removing Items from a collection -
Can anyone give me any examples of how they would remove several items from a collection without getting a "subscript out of range " error. I have a collection of maybe 60 items and most of them due to validation will be removed leaving me with around twenty, the thing is


Collections Index Problem..HELP! -
I filled a listbox and a collection with customers at the same time, when I remove an item from the listbox it will adjust the index automatically, lets say If I have 3 items and remove one, the last item's index will be = 1, but I also removed it from the collection, but the collectio


Comparing info in a Collection -
I am currently using a collection to store data about products. I want to compare fields in 2 different collection items, and then sort by which has the greatest number in the collection item that is being compared. For example I have: Collection Item 1 has a field names matches


Moving Collection Items -
I've never used a Collection before and I was wondering how would I go about moving an item from one index to another? I want to display the item that has an index of 0 and then remove it form the collection at a certain interval. Then I want to move all teh other items up a spot in


Spanner potential -
Alright I'm prepared for being elevated to 'spannerdom' here. I've got a class which, amongst other things, will return a collection (Property set/get). I set another collection in the calling form to equal the one in the class (set myFormCol = myClassCol). When I remove an item f


2 Listboxes, Removing the item -
Hello everyone again :-) Hope your day is going good! I'm stuck on another little problem I'm somehow managed to conjure up. You see, I want to remove 1 item (first) from the listbox but in turn it will also remove the parallel item from a second listbox. For example, first is


Collection/Array -
Hello, Please help me to solve this easy problem (easy to you but not to me). I have this block(I, II) and name(A, AB). Their combination is 4 and put in a collection. Each item in this collection (i.e. I_A) points to few records. There're many items in each record and one of th


Simple code for remove from Collection . -
Hi, Let say my collection got -a -b -c can anyone provide me the code to remove a and then b and lastly c from the collection. i=0 do until i =2 collection.remove i=i+1 loop is this the correct code ?? =) thanks


raising events from a collection of class's -
I have a collection of class's. I am raising an event in these class's but am finding it difficult to see how i get this event into my collection and into the calling program. The collection is a class itself with the usual, Add, Remove, Item. Any help or suggestions greatly appreacit


Checking for instance of string in collection -
Hello folks, I'm looking to make my own duplicates remover whichout using others available and am using a collection for this, as a collection I beleive can only hold one of the same item once, if there any method available that can check the current collection for a item already house


Struggle with collections -
Is it possible to know on what index you are in your collection? I work with VB6 but because I'm a straight object oriƫntated [Edited by MartinLiss]I work with classes (yeah right). So I've got a collection of this class. Problem is on a certain moment I want to change the data of one


Collection question -
Hello- I've created my own class and collection called Users. Basically the User Class just has a bunch of property statements and the Collection has your basics... add, remove, count, and item. What I want to do is something like this: set objUser = colUsers.Add(rs.field


collections help please!!! -
What exactly does a collection do? if i set a new collection in my form will i be about to use the collection in other forms? what is a collection of classes are there?? can only show me basics of a collection with examples add , remove , items etc keywords? understanding is m


Is there any function similar to pop() in visual basic -
Doesnt matter what control or object.. string, collection, listbox, whatever i need a pop function one that will remove an item from a list, and store its value in a variable the reason i need this is because im making a multithreaded app that will be doing a lot of things at o


Looping thru a collection.... -
Hi All, I have a problem looping thru a collection. Can anyone please help me out with this...... I have this following code..... Public mcolContacts As New Collection Public Sub Add(CustomerID As Long, SiteName As String, ContactName As String) Dim udtContact As ContactType


Collections without methods! -
found an example!! Take the Drives collection of the FileSystemObject. It is a collection of the Drive object and yet this Drives collection has no add,remove methods only Count and Item properties. In other words it is read-only and you can go: Code: For each Drive in Drives


Object.Collection.NewEnum -
Can someone explain what the NewEnum property means for a collection. I have a Class with a Collection inside it. The properties: Item, Count, and NewEnum. Ther are also Add() and Remove() methods. What exactly is the NewEnum property. I read somewhere that is has to do with


Are item values in collection read-only -
Hi! I have two problems. The first one is that when I try to assign a value to an item for a collection, an error is returned dim col1 as collection set col1 = new collection col1.Add 1, "first" col1.Add 2, "second" col1("first") = 3 ' error


Reorder collection & Listbox -
I'm trying to reorder a collection that is displayed in a listbox. I need to keep the key of the collection items the same as their corresponding listindex. THe code I'm using isn't working properly but I'm not sure what it's doing exactly. I just know it's not moving the selected i


Help me ,,,, 1 question only. -
Hi, theres some thing wrong with my code, can anyone point out the error to me. i can't assign the value of col item to b1 . ************************************* Set col as new collection For i = col.Count to 1 Step - 1 b1 = col.Remove i Next i ****************


enumerate collection in RichTextBox -
How do I print the items in my collection in a RichTextBox. If I try to show the items in my collection in debug.print, all the items in my collection show. So I know I have the enumeration part set up correctly. If I try to use the same process in the RichTextBox, it loops through


Collection Objects and Bookmarks -
When a record(s) in a Datagrid has been "Bookmarked" using a Collection object and SelBookmarks.Item, how do you specify, or pull out, a specific field? This code was used to "Bookmark" a specifc record(s): Option Explicit Dim colMarks As New Collection Dim i


[2005] Retrieve collection item without iterating entire collection -
I have a class that inherits from CollectionBase. I want to retrieve a particular item without having to iterate over the whole collection. It seems like all the examples I have seen require you to overload the IndexOf which simply iterates through all the items looking for a particu


Labels collection... -
I have a prob which may be able to be solved by a collection... Can someone give me quick runthrough on how I could create a collection of labels, and set their properties. I would like to reference them by an Index, not a Key. (I'm using a collection 'cause I want the Remove me


Collection item exists -
Hi All, I am trying to write a general function to test if a collection item exists. I have managed to do this for a specific collection, but i would like the function to be able to accept a passed collection. for example, itemExists(collection) would return true or false.


Requery - VB Simple -
Morning posties... I'll lay down a bit of background info 1st. Have a database. Table called Jobs and within this table there is a field called Internal (True/False). In VB a have a collection which comprises of records from this table. The SQL statment is: "SELECT * WHERE


adding to a collection -
I'm unfamilar with how to add an item(record) to a collection. I've already established the collection but keep getting errors on the add. My code looks like: collection.add ( When I put the first ( in place VB opens up this info box listing all my collection elements and their


Removing Runtime controls using Excel 97 VBA -
I have successfully added controls (i.e., check boxes) during runtime. I can remove added controls using the forms (userform1.controls collection). However, I would like to be able to create my on collections in order to keep track of runtime added controls by contol type of contr


item collection properties -
HI, anybody knows how to make something like this??? collection.item(1).property1=10 I did the collection part, and it works, but I don't know the proerties part. Thanks!!!


check if a special item is member of a collection -
There is a collection packed with items. each item under its specific key. when I want to find out if a special item is member of the collection, I try something like this: IF myCollection.Item(KeyInQuestioin) is nothing THEN msgbox "there is no item to find by KeyInQuestion


Edit/Display/Deleting from a Collection -
Class/collection newbie questions for a homework assignment. Here we go: 1 form (textboxes to accept data and add, edit, display data in the collection) clsMotor (with defined properties for the class) clsMotors (collection that contains methods for saving, deleting, editing, disp


delete from collection -
This is in connection with the previous thread that I posted about collection http://www.vbforums.com/showthread.php?t=347980 i want to add a Delete method in Database class, if this is triggered it should remove the item from the current collection, should i make an event method


Key for items in a Collection -
Hi, I have a problem. Removing an item from a collection, and then adding a new object with a Key like the one of the deleted item, I get a message "This key is already associated with an element in this collection (error 457)". What can I do to be able to reuse the dele


adding a collection to an arraylist collection -
for instance, i have a people class and a people collection. i would like to create a phone collection which consists of phone class and phone collection and then attach this to the people class object. so, in effect, i can call each people item and have the phone collection


Collection Help -
ok I'm trying to set up a collection to store multiple properties per Item. (e.g. I want it to store partnumber, description, etc in the same collection Item) There will be multiple Items in the collection with the same info. I am trying to distingush between the different items by