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

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
Dim key As String

With udtContact
.CustomerID = CustomerID
.SiteName = SiteName
.ContactName = ContactName
.Selected = False
End With
key = "CID:" & CustomerID
End Sub

Now I have 2 conditions
1)I want to remove the item if it already exists and add the same item with the updated value OR
2)Add a new item if it is not present in the collection.

The code for this is code is as follows
if key exists then
mcolContacts.Remove key mcolContacts.Add udtContact, key
Else
mcolContacts.Add udtContact, CStr(key) End If


 

selecting objects form a collection depending on their properties values - possible -
Once I stored some objects of myClass in a Collection, is it possible to select some of them without looping through the collection and get them into another collection (depending on their properties values)? And if not, how efficent is it to loop through a collections objects to ch


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


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


Find an item index in a collection without looping -
Is it possible to find the index of an item in a collection by its text without looping?


A matter of Class -
Hi, If I have a class, which is a collection wrapper, and it has classes within it, which are also collections of classes. So it's essentially a collection of collections. My point is: Can I just clear the master collection, without looping through and clearing all it's child


"System.Collections.IEnumerable" Gives you Object Collection Looping. What else -
Hi Guys, "System.Collections.IEnumerable" Gives you Object Collection Looping. What else? Set "System.Collections.IEnumerable" in a Collection clasee to get the following functionality For each ObjX in ObjXCollection MsgBox ObjX.Name Next ObjX


eliminating dups -[Resolved by MartinLiss] -
I have a collection of objects that have a value property that is a string data type. Within this collection there may be objects that have values that are duplicated. I want to create an array of strings that contains distinct values. Currently I am looping through the collection


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


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


Collection in dll be accessable from other dll. -
Ok, here is what I need. I need to have a dll that will hold a collection of connected sockets. A third party dll needs access to this collection. I have tried this many times before, but whenever I try to access the collection which I tried making static, the thrid party dll just gets


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


[Word] Formfields question -
Hi, i've created a few word documents with formfields in them. each has a distinct name. is there an easy way to check whether a formfield with a certain name is present in the formfields collection of a document or not? (without looping the entire collection of formfields in th


[2005] Question about looping through controls -
When looping through controls inside of a container, what is the logic behind the order of each control being looped? Basically I have about 5 checkboxes in a container and I am looping through them all to find which is checked, but it seems it is looping from the bottom to the top,


Collections, classes and New() -
I have a "master" collection and a temporary collection, each is based on a class that I defined. The "master" collection exists as a private form variable. The temporary collection exists in a sub on that form. In the sub I set my temporary collection equal to t


While looping, skip current item if it meets a certain condition -
I am looping through a collection of files, putting in the filesize as I go. However, I have a delimiter that changes to the previous directory in the path (EX: It will change to C:\Dir1 if I'm in C:\Dir1\Dir2.) The problem is that it will also include that in the loop, since it's


How to get values from session objects -
I ahve a collection object saved in the session I have also declared a new collection object When I do the following(written from memory ) dim newcoll as new collection newcoll = Cast(Session("Collection"), Collection) I get only a reference to the session colle


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


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


for-next looping.. -
hello there, I learned to print 10 images on the screen using FOR LOOPING. (for x=0;x<10;x++); document.write('some.jpg') this prints ten images side by side.. But What Iwant to do is clear all those 10 images one by one usin FOR looping...I think I need a setTime and ho


Garbage Collection in VB -
Do you have to do garbage collection in VB like you do in C? Or does VB do automatic garbage collection like Java? If I must free up the memory used by VB, what are the commands? I did a search for garbage collection in MSDN and got nothing related to VB. I am assuming some G


return a collection from a fucntion -
Hi I have a command button when clikced goes to a class module function, which get a collection of all mails in my Inbox. I need to return the collectoin to myform and be able to access the collection. How do i do it????? When i do the processin in same Sub it works fine. But when


Collection in Excel -
Sorry to be asking about Excel in here but I've searched and noticed there are people in here who seem to know alot about it. I am working in VBE and though it is very much just like VB6 I'm not used to working with spreadsheets. I am looping through the rows and columns looking for


Returning Month From DateRange -
hi all, I have a pretty good idea how I want to do this (looping) but I'm thinking there may be a faster more efficient way to do it that you guys may know of. here goes: I have an input of a begindate and an enddate. Basically i'm just trying to get the month and year of every


(RESOLVED)Collection in Excel -
Sorry to be asking about Excel in here but I've searched and noticed there are people in here who seem to know alot about it. I am working in VBE and though it is very much just like VB6 I'm not used to working with spreadsheets. I am looping through the rows and columns looking for


Looping a Collection/Hashtble -
anyone used hashtable collection class yet that can help me here.. i have a dll that has a public Hashtable that holds some values of another class code to add to the hashtable Code: UserProps clsProp = new UserProps(); clsProp.UserHandle = Handle; clsProp.UserID


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


Creating a collection -
Hi. I have a small problem about creating a collection. I sure know how to loop through all controls of a collection (for each ctl in form.controls). The problem is I would like to CREATE such a collection myself. (Ex.: I will add to a collection all the textboxes that the user have


Array, Collection, or **Resolved enough** -
I'm working on a process that is going to loop through a recordset a few times (different dataset each time). I need to keep track of the ID of each of the records I loop through. Here's the catch, sometimes, the same ID may appear in one or more of these iterations. When I'm done wit


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


Transferring contents of server collection to local collection -
Hello folks, I have an ASP page which uses a server based dll to instantiate a collection which is used to poulate a list box. The collection is two columns and I want to use the second column to populate a text box based on the row in the listbox which is selected. I am not an A


Problem with control collections -
Hi, When we loop through controls collection (For ...each)is it possible to loop through the ctrls in same order as taborder if yes how .Because in my case looping is starting from some random point. Thanx Murali


Advanced collection -
Can anyone tell if this is possible in VB6? I have an object structure like this. Rootobject --companycollection ----company ------contactcollection --------contact But now I want to make another collection that points directly into the existing contact collection. Rootob


Collection v/s Datatables -
What is better in terms of performance and resource-use, a Collection or a DataTable? What are the different situations in which a Collection will work better than a DataTable, and vice versa? What would be the ideal method for replacing a Collection in code with a DataTable?


Question about For Loop -
What application could the For Loop be used on? When could this be useful in a program? How could the for loop be used when looping through a collection of controls?


Passing VB.net collection to VB6 com dll -
Hi, I have a VB6 COM DLL that expects a VB6 style collection object as parameter to a method. It seems like I can not pass a VB.NET created collection. What do I have to do? I can not make any modifications to the VB6 COM DLL. The VB6 DLL accesses items in the collection by a


Populating collection of collection -
Hi, The code loops through a list of machineNames and for each machinName (There are 18 of them), it loops through a number of settings (There are 39 of them). At present I have a generic collection to populate all the settings which is called settings. As I am looping through the s


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


Loading collection from file -
I have created a student collection, attached below, to add student information to a file. What I cannot figure out is how to modify the collection so it saves the collection in a file or database before the program exits. When it starts up, it needs to load the collection from that f


How to get Unique List from a Collection -
Hi I have a collection in vb which has collection of strings. Is there any easy way to get unique list from the collection or do we have any thing similar to collection that gives us unique list easily. We have HashSet in java which gives us unique collection.So do we have any