473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VB Collection class

553 512MB
Using VB Collection, there is a restriction that only one member can be associated with a particular key.

E.g:

ob.Add "user1", "key1"
ob.Add "user2", "key1" <---------- Error - one key can have only 1 member

Please advise of something else that can accomodate more than 1 member for the same key

Thanks
Aug 1 '07 #1
7 2377
MikeTheBike
639 Expert 512MB
Hi
Using VB Collection, there is a restriction that only one member can be associated with a particular key.

E.g:

ob.Add "user1", "key1"
ob.Add "user2", "key1" <---------- Error - one key can have only 1 member

Please advise of something else that can accomodate more than 1 member for the same key

Thanks
I know (assume!) ob is an object collection, but a collection of which objects ?

MTB
Aug 1 '07 #2
questionit
553 512MB
MTB

i dont understand what you mean.
but I've got this:

Private ob As Collection

Hi


I know (assume!) ob is an object collection, but a collection of which objects ?

MTB
Aug 1 '07 #3
ADezii
8,834 Expert 8TB
Using VB Collection, there is a restriction that only one member can be associated with a particular key.

E.g:

ob.Add "user1", "key1"
ob.Add "user2", "key1" <---------- Error - one key can have only 1 member

Please advise of something else that can accomodate more than 1 member for the same key

Thanks
To the best of my knowledge, each member of a Collection must be defined by a Unique Key, so the Collection route is out. You may be able to accomplish this via a Multidimensional Array or a Table Structure where the combination of User and Key (Composite Key) is Unique so that multiple Users can be assigned to the same Key. You can then reference the Users assigned to a specific Key by SQL, Recordset, etc.
Aug 1 '07 #4
NeoPa
32,556 Expert Mod 16PB
Hi

I know (assume!) ob is an object collection, but a collection of which objects ?

MTB
In Access the Collection object is not restricted to contain objects of any particular type.
Aug 1 '07 #5
NeoPa
32,556 Expert Mod 16PB
Using VB Collection, there is a restriction that only one member can be associated with a particular key.

E.g:

ob.Add "user1", "key1"
ob.Add "user2", "key1" <---------- Error - one key can have only 1 member

Please advise of something else that can accomodate more than 1 member for the same key

Thanks
More fundamentally, do you really want to store two items with the same key. The answer's almost certainly "No."
Do you have the parameters the right way around?
The key parameter should be a unique identifier for that particular object (instance of an object technically).
Aug 1 '07 #6
questionit
553 512MB
Yes in my example, i need to associate more than 1 member with one Key

Its simply 1 to many relationship.

I thought there would be something similar to Collection in VB that i can use. But if there isn't i would go for making an 2D array.
More fundamentally, do you really want to store two items with the same key. The answer's almost certainly "No."
Do you have the parameters the right way around?
The key parameter should be a unique identifier for that particular object (instance of an object technically).
Aug 1 '07 #7
NeoPa
32,556 Expert Mod 16PB
It doesn't make a lot of sense to store them all in the same collection then I suggest.
What if you store the one side of the situation in one collection and the many side in another. Just as in a database, the many key could consist of the one key as well as an extra unique part to identify it uniquely.
Aug 1 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Marc L'Ecuyer | last post by:
Hi, I have a collection class derived from CollectionBase. This collection can add items of my class MyItem. In my class MyItem, I have a Selected property. When this property is set to true, I...
0
by: Sundown | last post by:
I am trying to create a custom button control for the web that, when clicked, disables and changes the text of itself and a bunch of other controls (in the collection). My goal is to end up with a...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
4
by: Michael | last post by:
Dear all .. If I want to use develop a user control and declare a public property which the type is System.Windows.Forms.GridTableStylesCollection For example : Public Class LookAndView...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
6
by: Arthur Dent | last post by:
How do you sort a generic collection derived from System.Collections.ObjectModel.Collection? Thanks in advance, - Arthur Dent
6
by: Erick | last post by:
I've created a class called Procs and a collection class called Processes which uses a hastable object to store the Procs. Now i want to enumerate with the "For each" to extract all the Procs in...
1
by: holysmokes99 | last post by:
I have run the VB.Net upgrade wizard to get a vb6 project up to VB.Net 1.1. This is a class library that is referenced by another VB6 app. I have exposed it to for COM access. The problem is that...
3
by: gasfusion | last post by:
Hey guys. I'm building an object collection which will be a part of a Data Access Layer i am currently working on. However, i am having some issues iterating through a collection. This is what...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.