Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Open form by variable

Hi
do u have any idea to open a form dynamically by putting the form name in some variable and open the form using that variable.
eg.
dim x as variable
x.show 'must open the form whose name is stored by x

thanks

0
binita11
Asked:
binita11
1 Solution
 
fatalXceptionCommented:
If you have a form, say called frmUserInput:

then you can say this:

Dim newForm as frmUSerInput

and later on
set newform = new frmUserInput
newform.show vbmodal and so on.

HTH
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Assuming VB6:

Private Sub Command1_Click()
    Dim frmName As String
    frmName = "Form2"
   
    Dim frm As Form
    Set frm = Forms.Add(frmName)
    frm.Show
End Sub
0
 
GuryTraubCommented:
if I understand correctly what you mean, and you are using .net then you can use reflection to load a certain class dynamically, meaning load it's assembly (dll file), and then call one of its constructors (or other methods/properties/etc) then you'll have an object which you can case to a window.form.

take a look at the reflection samples in the help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now