Forms instances

mistaken_myst

Active member
Joined
Oct 29, 2007
Messages
25
Programming Experience
Beginner
dim f1 as Form1
dim f2 as Form2

Is there a way to verify that 'f1' is an instance of 'Form1' ?
 
Usually:
VB.NET:
Expand Collapse Copy
If TypeOf f1 Is Form1 Then

End If
You can also do:
VB.NET:
Expand Collapse Copy
If f1.GetType Is GetType(Form1) Then

End If
 
ok, Thanks..

'f1.GetType.ToString' was not working but 'If f1.GetType Is GetType(Form1) Then' is working perfectly..

There's another question I'm not sure:
From frmContainer:
dim f1 as new Form1
f1 .MdiParent = Me
f2.show()

From Form1:
dim f2 as new Form2
f2 .MdiParent = frmContainer.ActiveForm
f2.show()


I hav used this code above, but now I hav noticed that 'frmContainer.ActiveForm' is the same as 'ActiveForm' & it simply refers to the 'Active form' in my Application.
The Active form in my Application is always the 'MDI Container' (frmContainer) since every form I instantiates is a MDIChild of this Container..

But I hav just found another way: f2.MdiParent = Me.ParentForm, Is this one better than the previous?
 
f2.MdiParent = Me.MdiParent
 
Back
Top