PDA

View Full Version : form.close VS form.dispose VS form=nothing


haowei
03-24-04, 06:20 PM
can any one tell me what's the difference between these statements?

I was encountering a problem that when i click the close button of a form, it throws me an exception when i try to say
if isNothing(form) then
.....
end if

it's obvious that the effect of the close button is not the same as
form=nothing
so how do i test if form is "closed"?

what about form.close and form.dispose?

Hive
04-16-04, 07:11 PM
I never figured this one out in my last app i tried. Gonna try and find out how in my new one though cause i'll need it.

Maybe:

If Me.Disposing = True Then
....
End If

Or make a Try/Catch/Finally method.

haowei
04-18-04, 11:28 PM
My solution:
If IsNothing(frm) OrElse frm.IsDisposed() then
.....
End If

schiavo
05-02-04, 10:05 PM
Good research project for extra credit. and you should include the more standard way to close: "unload me"

Offhand, to see if a form is loaded, I'd look at the FORMS collection. Not sure if that's the "purist's" way, but I'd try it at 11:00 PM kind of thing ...

dim x as form
for each x in forms
if x.name = "Form99" then msgbox "form 99 is infact loaded"
next x




can any one tell me what's the difference between these statements?

I was encountering a problem that when i click the close button of a form, it throws me an exception when i try to say
if isNothing(form) then
.....
end if

it's obvious that the effect of the close button is not the same as
form=nothing
so how do i test if form is "closed"?

what about form.close and form.dispose?