Ouch. You should never pass something around as an object that has a deeper
base class. Clearly all Windows forms derive from
System.Windows.Forms.Form, so you should have defined the object as that
instead. Something like this:
Sub MyFunction (passedForm as System.Windows.Forms.Form)
' Do Something with passedForm
End Sub
You could also do this, if you have already imported a reference to
System.Windows.Forms
Sub MyFunction(passedForm as Form)
' Do something with passedForm
End Sub
If you are looking for a particular instance of a form, or a particular form
class, you could define the referenced object in that particular class. The
other choice you could have is to check the type of the passedForm object,
and see if it implements the class or interface you are expecting, and then
cast it into that class. All depends on what you're trying to do... just
don't pass it as an object!
Ryan Gregg
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:Ox**************@TK2MSFTNGP11.phx.gbl...
private function fntMyFunction (objForm as object)
'my function getting a form as paramater
end function
than you can call the function like this:
fntMyFunction (frmMyForm)
If you know alreaddy what kidn of form you're going to use you better use:
private function fntMyFunction (objForm as frmMyForm)
-> This way you can use the methods of the form.
"stanuf" <sf*******@samsa.com> wrote in message
news:uT**************@tk2msftngp13.phx.gbl... Hi!
I am new to vb.net and have a question on how to pass a form to a function. Could someone point me to an example or give me a quick example on how
to do this.
Thank you
Stacy