Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Generic method within an object
Message
 
À
07/01/2002 02:28:38
Information générale
Forum:
Visual Basic
Catégorie:
Contrôles ActiveX
Divers
Thread ID:
00601410
Message ID:
00601439
Vues:
16
VB doesn't have this feature. Have a look at the CallByName statement. Be advise that this method can slow down your application if your component is heavily executed.

>We have to build an object which will receive two parameters. The first one will be an object followed by a method name of that object. Basically, this object will be a wrapper for several method calls for the object we pass. So, for example, the object I will pass may have the following methods:
>
>GetCustomer()
>GetCity()
>GetState()
>GetCountry()
>
>Each of those method also accept one parameter. So, basically, I am looking for something like this:
>
>
>Sub GetValue(loObject As Object,lcMethod As String)
>Dim lcValue
>lcValue=''
>loObject.&lcMethod(lcValue)
>Return lcValue
>End Sub
>
>
>We have about 80 methods. They all do the same. This object in Visual Basic should use one method to do them all. So, when passing the method name, the object should be smart enough to evaluate the method of the object to call. I have used the & approach here which is an approach we could used in Visual FoxPro. How can I do that in Visual Basic?
>
>Not only that we have 80 methods. But, when we will add additional methods, we won't have to change this object as it will be generic.
É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