How can i call a Form from a MDI Window?
How can i set a Form as a child of a MDI Window?
"Form1.Show" works in VB 6.0, now does not work in VB .NET.
Any solution VB .NET to show a Form?
Please guide. 10q!
Printable View
How can i call a Form from a MDI Window?
How can i set a Form as a child of a MDI Window?
"Form1.Show" works in VB 6.0, now does not work in VB .NET.
Any solution VB .NET to show a Form?
Please guide. 10q!
To show a form do this :
VB Code:
dim myform as new yourform myform.show
To create new child form just call this little sub .
VB Code:
Private Sub NewChild() Dim fc As New YourChildform() fc.MdiParent = Me fc.Show() End Sub
In my case, I try to open Form1 from mdiForm.
This is how i wrote in mdiForm:
Private Sub mnuFileNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click
Dim frmNewEntry As frmEntry
frmNewEntry.Show()
End Sub
Is this correct?
But why the error message below keep on occur?
"System.NullReferenceException: Object reference not set to an instance of an object."
Please guide. Thank you.
You need to create new(instaciate) object of frmEntry by using New keyword. You have to read more about OOP in .NET . So your code should look like so :Quote:
Originally posted by albertlse
This is how i wrote in mdiForm:
Private Sub mnuFileNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click
Dim frmNewEntry As frmEntry
frmNewEntry.Show()
End Sub
VB Code:
Private Sub mnuFileNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click Dim frmNewEntry As New frmEntry frmNewEntry.Show() End Sub
"System.NullReferenceException: Object reference not set to an instance of an object." is usually an indication that you did not use the "New" keyword to instantiate the object prior trying to use it.
It's working fine now! Thank you!