|
-
Mar 4th, 2002, 04:25 AM
#1
Thread Starter
Addicted Member
MDI form
Hi everybody,
I want to create an application where I want to use a MDI form. As in any windows application i want to add the NEW command to the menu, using which i can create a new documnet. What I want to do is create a prototype of the child form and to create an instance of the prototype whenever i click on the NEW command. How can this be achieved? I have read that u can create a form which can act as prototype and declare an array of that prototype. BUt i don't want to limit myself to the ubound of the array declared. I want to let the user create as many instances as he/she wants.
Please can anyone help me.
Regards
Samir
-
Mar 4th, 2002, 04:36 AM
#2
Bouncy Member
you can use a dynamic array.
this is an array where you don't specify the dimensions when you declare it, you can then change the no of dimensions and the upperbound etc during runtime. Theres plently of info on them in MSDN.
However you could also consider using a collection rather than array since you will be storing objects...
-
Mar 4th, 2002, 04:39 AM
#3
Fanatic Member
Hmm, you dont neccesarily need an array or a collection.. Remember that th form will be added to the generic forms collection, and child collections...
Create the template form (EG frmDoc)
' Behind the new menu item...
Dim oNewFrmDoc as frmDoc
Set oNewFrmDoc = new frmDoc
oNewFrmDoc.Show
' Dispose of our refrence to the form.
Set oNewFrmDoc = Nothing
Leather Face is comin...
MCSD
-
Mar 4th, 2002, 04:41 AM
#4
Thread Starter
Addicted Member
Hi Darre1
HI,
Thanx for ur reply darre1.
Can u please elabordate on COLLECTIONS. What is a collection where do we use it. I am very new to this field so ur advice will be a great help to me. And if possible can u please give me ur email id so that i can mail u when i need ur help.
Thanx.
Regards
Samir
-
Mar 4th, 2002, 05:05 AM
#5
Bouncy Member
collections are dead easy to use.
here's an example...
VB Code:
Dim colForms As Collection
Private Sub Form_Activate()
Dim f As Form
Dim f2 As Form
Dim i As Long
'setup objects to go into collection
Set f = New Form1
f.Tag = "abc"
Set f2 = New Form1
f2.Tag = "xyz"
'create new collection
Set colForms = New Collection
'add forms to collection
colForms.Add f
colForms.Add f2
'read data from objects in collection
For i = 1 To colForms.Count
MsgBox colForms(i).Tag
Next i
'remove objects from collection
For i = 1 To colForms.Count
colForms.Remove (1)
Next i
MsgBox "there are now " & colForms.Count & " items in colForms"
End Sub
like the above post said though, you're forms will all be accesible through the global Forms collection anyway, but you can have your own if you wish, and then you can add and remove whatever you want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|