By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

Accessing form from module

P: n/a
dear sir

In my vb.net window application i have the MDI form MainMDI and child form form1 adn module as MainModule
In my MainMDI Parent form i have one toolbar i.e. tbraction. I am trying to show the toolbar when i am displaying form1 (child form) . when i close the child form i want it to be hiddeni.e. invisible

i wrote the code in MainModule as

Friend Module MainModule

Friend frmMDI As MainMDI

End Module

and in the child form closed event i wrote:
Private Sub form1_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
On Error GoTo errHandler

frmMDI.tbrAction.Visible = False
Exit Sub

errHandler:
If Err.Number <> 0 Then
MsgBox(Err.Number & vbCrLf & Err.Description)
End If
but while accessing the code it give me error

Error 91
Object reference not set to an instance of the object
Please let me know how to solve this error.
thanks
Mustafa


Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mustafa,

Which object is throwing that error?

if it's Friend frmMDI As MainMDI then you need to set it to something.

Friend frmMDI As New MainMDI?

I'm not too sure since I never liked using modules, but too all their own. You might need to take time in examining it.

Lastly, I see On Error GoTo.. That made my skin crawl.

Try
' code
Catch exp As Exception
System.Diagnostics.Debug.WriteLine(exp.ToString)
MsgBox(exp.ToString)
End Try

^ that's better means of error handling.
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.