Closing events ?

  • Thread starter Thread starter HANG LAM
  • Start date Start date
H

HANG LAM

hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the
'X' icon in the top-right corner of a form and the closing event coming from
the Form.Close() command.

I don't want the user to be able to close the application by clicking on the
"X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.


Thanks,
Scott
 
Hi Hang,

This is probably not the most elegant way to do this, but this will work:
1. set a public variable in the declarations section of the form with
Public closetest As Boolean = True

2. in the close button event, enter

closetest = False

Me.Close()

3. in the closing event of the form enter

If closetest = True Then

e.Cancel = True

End If

HTH,

Bernie Yaeger
 
hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the
'X' icon in the top-right corner of a form and the closing event coming from
the Form.Close() command.

I don't want the user to be able to close the application by clicking on the
"X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.


Thanks,
Scott

Here's an article that discusses one way to accomplish this...

http://www.fawcette.com/archives/premier/mgznarch/vbpj/2001/11nov01/qa0111/qa0111.asp

HTH
 
Back
Top