Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic creation of Public properties in a Class
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00419539
Message ID:
00419983
Vues:
18
>>>>>>>>>>>>>>>>>>>>

>Hi all,
>i am not sure if what i want to do is at all possible in VB but here goes:
>i am currently creating an instance of a class, and based on a variable in the form need to create extra Public Property Get() AS STRING
>can you dynamically assign these extra properties in a class instance?

No you can't add properties at run-time since classes are compiled.

Maybe can you create a structure of variant containing the name of your property and its value.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Depending on the circumstance, a collection may help. I needed to add props at run-time recently, and instead added a collection called "colCustomProps". A method called AddToCustomProps adds a new property, with an Index on the priperty name I want to use.... another method called GetFromCustomProps returns the value.

It worked fine for the situation I was in, might prove helpful for others, too....
The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts. - Bertrand Russell
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform