Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call form with string
Message
 
À
11/09/2005 07:43:06
Teddy Win
Bytel Information Technology
Jakarta, Indonésie
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
01048513
Message ID:
01048663
Vues:
19
Copied from a UT-FAQ:

Title

How to load a form using its name stored in a variable

Summary

If you store form name in a database or you simply have the form name in a string variable, you can load it using the Forms collection.

Description

You can use this code:
Private Sub Command1_Click()
Dim frmX As Form
Dim strFormName As String

    strFormName = "Form2"
    Set frmX = Forms.Add(strFormName)
    frmX.Show
End Sub
To use this code, you should have at least SP3 of VB6. Prior to this SP, the code will behave correctly in the Visual Basic development environment, but fails with an error (Run-time error '-2147417848 (80010108)': Automation error) when the application is made into an executable.

You can read more on the fix at http://support.microsoft.com/support/kb/articles/Q194/9/12.ASP


>Dear VB Expert,
>
>I store form name to a string (ie. mFormName = "Form1") ... how to call form by using string?
>
>Dim mFormName as string
>mFormName = "Form1"
>
>
>I need tips ..
>
>many thanks in advance
>
>Regards
>Teddy
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform