How do I load multiple instances of the same form?
I get an "object already loaded" error when I use frm.show
Printable View
How do I load multiple instances of the same form?
I get an "object already loaded" error when I use frm.show
'this what you are after
Code:Private Sub Command1_Click()
Dim frm As Form
Dim x As Integer
For x = 1 To 4
Set frm = New Form1
frm.Visible = True
Next
End Sub
Thanks, Joe.
How do I distinguish between the forms once I've loaded them?
I'm only able to unload the one that I loaded "directly" (load frm) and not the one that I loaded through a variable (dim frm2 as Form, set frm2 = new frm)
Unload frm2 ?
best thing is when you new up an instance is to add it to a collection. The you have somewhere to retrieve them from.
You can use the handle of the form as a key for it, so if you want to retrieve a specific form you can. You can always create your own keys as well.Code:
dim frmInstance as form1
set frmInstance = new form1
colForms.add frmInstance, cstr(frmInstance.hWnd)