All i want to do is access my property from a parent Form in vb.net Forms.
but it won’t let me do
Dim formParent1 As formParent
Private Sub search()
formParent1.propertyName = 1
End Sub
but it gives an error at formParent1.propertyname = 1. Saying “Object reference not set to an instance of an object”.
but i may not use
Dim formParent1 as formParent = new formParent()
how can I access this propery, I am new at VB.net
best regards
If I understand you correctly, that code is inside a child form of formParent. To use a reference to the current formParent you need to pass inside the child form a reference to this current formParent.
So in the formParent, when you start the execution of the child form, write this:
in the form child constructor save the passed reference to the global variable formParent1
now you can use the reference formParent1 inside the child form without initialize another formParent
For example, assuming that the formParent1 contains a public property named
SearchResult, when you complete your search you call: