-
Can someone help me by replying this msg about how to open a new window from a button in a form ?
I want to open a new form from the existing form i have created from the button of the existing form.
If I use the method of MDIForm, the form will be created inside the existing form.
I want the new form to be loaded not inside the existing form.
pls..... someone help me ?
-
Something like this.
Code:
Private Sub command1_click()
'myNewForm is the form that you wish to show.
myNewForm.Show
End Sub
-
THANX
-
...to make it on the fly
Private Sub Command1_Click()
Dim newform As Object
Set newform = New Form1
newform.left = 400
newform.Top = 2000
newform.Visible = True
End Sub
-
Shouldn't you Dim it as a Form ??
-
?
yes I suppose so, but object works as well..is there
a difference?
-
Yep.
1. Dim an object as the correct type, in this case a form, and you will be able to see all of the correct properites and methods with VB's type ahead thingy.
2. If you dim a variable as an object, you get late binding. If you dim it as the correct type, you will get early binding, which is a lot quicker.
-
Ok
..thank you...
I'll adjust my notes......
I'll adjust my thoughts...
very good explanation.....
-
When dimensioning as Form versus Object, are not also allocating memory correctly from the start ? Therefore saving memory space and probably execution speed...
A little like declaring a variable as Double versus Variant. The compiler knows immediately how much memory to reserve.
Is that right ?
-
No. Not with objects. You are right about variant versus othere types, but objects are diferent.
A Variable that is defined as an object is not actaully the object itself. It is just a 32 bit pointer to the object. As is a variable declared as a form. It is not the form, it is just a pointer to where the form is in memory.