Is it possible to check if an instance of a form exists? TIA.

Re: Form Instance by Oliver

Oliver
Wed Aug 17 07:22:25 CDT 2005

Niggy wrote:

> Is it possible to check if an instance of a form exists? TIA.

Do you mean a specific instance or just any instance at all? If you have
a variable of the type of your form and you don't know if you have
instantiated it yet, you can check for null:

MyForm myForm;
...
if (myForm == null)
// do something

Be aware that myForm will only be automatically initialized to null if
it's a class member (field), not if it's a variable in a method.

If you mean you want to find out whether just any instance of a form
exists, I don't think that's possible. You should store away the
references to forms you create, so you can later find out what you
created or not.


Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Re: Form Instance by Lloyd

Lloyd
Wed Aug 17 08:03:21 CDT 2005

Application.OpenForms
what about that hey?
2.0 required...

--
If you're in a war, instead of throwing a hand grenade at the enemy, throw
one of those small pumpkins. Maybe it'll make everyone think how stupid war
is, and while they are thinking, you can throw a real grenade at them.
Jack Handey.
"Niggy" <Niggy@discussions.microsoft.com> wrote in message
news:D8F0D1E7-30C0-487F-891D-FDB41BE3BA59@microsoft.com...
> Is it possible to check if an instance of a form exists? TIA.



Re: Form Instance by Oliver

Oliver
Wed Aug 17 08:46:27 CDT 2005

Lloyd Dupont wrote:

> Application.OpenForms
> what about that hey?
> 2.0 required...

Interesting, I hadn't seen that yet. I just tested it, though, and I
found out that you have to be careful: The OpenForms collection holds
only forms that are actually visible on screen (as the name suggests).
So it could be that there are any number of form instances that are not
in that collection because the forms aren't currently visible.



Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog

Re: Form Instance by Niggy

Niggy
Wed Aug 17 09:21:04 CDT 2005



If you continously dim a variable to hold a new form, will you eventually
run out of memory or does the dim replace the current instance of that form?

Re: Form Instance by Oliver

Oliver
Wed Aug 17 13:59:39 CDT 2005

Niggy wrote:

> If you continously dim a variable to hold a new form, will you eventually
> run out of memory or does the dim replace the current instance of that form?

If you "forget" the old instance of the form you just created, it should
be free to get collected by garbage collection (if there aren't any
other references to the same form held in other places). So at least
when there's not enough memory left (or a while earlier than that),
garbage collection will kick in and free a lot of those old instances
that aren't referenced any more.



Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog