Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create an object from scratch
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00449659
Message ID:
00449667
Vues:
8
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>Is there any way in VB, like you can in VFP, to create a generic object at runtime, and add properties to it dynamically? I am looking for something like VFP's AddProperty.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>No. PITA.
>
>Here's what I have done though: I use VB collections, and store the "property" names and values to them. So, rather than VFP's
 MyObject.AddProperty("LastName", "Vin") 
I execute
 MyCollectionObject.Add "LastName", "Vin" 
Later, instead of
 lcTemp = MyObject.LastName 
I execute
 strTemp = MyCollectionObject("Lastname") 
Collections work not just with text, but with numbers, objects, etc., so it tends to fit the bill in a lot of the cases I am dealing with.... But, nowhere near as elegant.
>
>Hope this helps.

Oh yeah. I knew about this, but wasn't even thinking of it. In fact, this is probably a better way to do what I am doing anyway.

Thanks...
Erik Moore
Clientelligence
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform