Hey Fergus,
Thanks for the explanation! I was not aware of this temporary location
behavior.
These calls are being made from inside click menu calls. As all of them will
need to check if the form is open and perform some other things too (as seen
on the first post) I decided to create a little procedure to handle all the
work. Why are you curious? Is that strange in any way?
Regards,
Giovanni Bassi
"Fergus Cooney" <filter-(E-Mail Removed)> wrote in message
news:ug3$(E-Mail Removed)...
> Hi Giovanni,
>
> ByRef creates a reference to the variable being passed into a method
so
> that if you change it within the method, the variable that it was called
with
> will change too. You know this, which is why you used it.
>
> However, when you use an expression instead of a variable, the
reference
> passed into the method is a reference, not to the variable, but to a
temporary
> location where the result of the expression is stored.
>
> In OpenChildForm (CType(m_objfrmAccounts, frmAccounts), ...), the use
of
> CType() makes it into an expression and so, within OpenChildForm(),
> objFormToOpen doesn't refer to m_objfrmAccounts but to the expression.
>
> What you'll have to do is change OpenChildForm so that it returns the
> child Form rather than setting a passed-in variable. Make the return type
of
> OpenChildForm be the highest class that is common to all the possible
child
> Forms. Then cast it to the correct type when assigning the result.
>
> || By the way, I don't know if it matters, but frmAccounts is
> || derived from another form using visual inheritance and not
> || directly from Form.
>
> As a general point, that's fine - as long as there's a Form somewhere
down
> the chain of inheritance (which there will be).
>
> I'm curious. Was OpenChildForm (CType (m_objfrmAccounts, frmAccounts),
> "CoairBR.Accounting.PayrollTranslator.frmAccounts") just an example or do
you
> have these calls hard-coded in this way? Are they from a list or
something?
>
> Regards,
> Fergus
>
>
|