Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I pass an object name to another form?
Message
 
À
02/04/2001 12:37:46
GW Gross
{Banned by Information Security Policy}
Lake Mary, Floride, États-Unis
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00490967
Message ID:
00490984
Vues:
8
>Here is the problem. I want to pass an object name to another form, then have that form instantiate the object. I have no idea how.
>
>I tried unsuccessfully, to add a new Property to the form and then use that property name, but that does not work.
>
>Here is what I tried:
>
>In the Calling Form:
>
>
>frmviewer.ReportName = "crBatchSummaryReport"
>
>
>In the Called Form:
>
>
>Private CRDesigner as String
>
>Public Property Let ReportName(InputName As String)
>
> CRDesigner = InputName
>
>End Property
>
>Public Property Get ReportName() As String
>
> ReportName = CRDesigner
>
>End Property
>
>Then in the load event I tried:
>
> Dim crReport as ReportName
> Set crReport = New ReportName
>
>
>This of course errors out, because it is using "ReportName" to define the object, but I want to use the value of "ReportName" which is "crBatchSummaryReport". I find a lot of places where I want to do this, but how do you get VB to use the Value of the string variable and not the variable name itself?

You can use:
Dim crReport as object
Set crReport = createobject(ReportName)
É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