Go Premium for a chance to win a PS4. Enter to Win

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

Multiple instances of a form?

Is it possibvle to have multiple instances of the same form in a project? Can I program one mdi child form so that i can call it to spawn multiple instances with different variables inside the main form? Thanks.
  - Dave
0
User501
Asked:
User501
2 Solutions
 
ShauliCommented:
After you create the first child form, you can do:

'assuming the child form name is Form1

Dim myForm As Form1
Set myForm = New Form1
myForm.Show


S
0
 
anvCommented:
hi User501.

yes u can have multiple instances of the same form using
the above code as givn by Shauli...

but when u say with different varaibles..what exactly u mean..

if u mean that the variables should store separate values for all instances.. then yes they will..

and if u mean u want to run different code depending on the instance or value passed while opening a form...then for that u can take a variable say OpenArgs.. depending on the value of this variable u can call ur code..

like
frm.OpenArgs = "1"
frm.show
in the form load of form1 wriet the following code

Select case OpenArgs
 case "1": 'do something
 Case "2"" Do Something
and so on..
end select
0
 
RejojohnyCommented:
u cannot have multiple instances of a mdi form .. but u can have multilpe instances of a normal form using the example that shauli menions above
0
 
redfordbCommented:
Remember that once you are finished with the form you need to free the memory that it was using.
ie Set myform = nothing.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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