Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic creation of class instances.
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00479835
Message ID:
00479973
Vues:
37
>Say I have cEmployee class and I want to create another instance on the fly, how would I do that? Other than:
>
>Set oCEO as new cEmployee
>Set oDeveloper as new cEmployee
>Set oJanitor as new cEmployee
>
>Maybe a collection of custom class objects are what I need but I am not sure how to, or even if, that is the answer...

For collection, you need a collection object and then you add your instances to the collection.

Dim x as Collection
Dim Y as cEmployee

Set X = New Collection

'Add a first employee
Set Y = new cEmployee
y. .... = ....
y. .... = ....
x.add y

'Add a second employee
Set Y = new cEmployee
y. .... = ....
y. .... = ....
x.add y
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform