473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

If e.Cancel Then Exit Sub in Closing event

I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

....snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments


Nov 21 '05 #1
2 1527

The event is broadcast by the multi-cast delegate just like any other
event. This delegate has no knowledge of the Cancel property or what
it is for. It always sends the event to all subscribed delegates.

Also, there are situations where you have multiple listeners of the
closing event and you want them to all fire off even if one of them
says to cancel.

If what you're doing doesn't need to run if something else cancelled,
then it's good practice to add this check at top of routine.

HTH,

Sam
On Fri, 7 Jan 2005 11:43:26 -0500, " Just Me" <gr****@a-znet.com>
wrote:
I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

...snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments


Nov 21 '05 #2
thanks a lot
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:22********************************@4ax.com...

The event is broadcast by the multi-cast delegate just like any other
event. This delegate has no knowledge of the Cancel property or what
it is for. It always sends the event to all subscribed delegates.

Also, there are situations where you have multiple listeners of the
closing event and you want them to all fire off even if one of them
says to cancel.

If what you're doing doesn't need to run if something else cancelled,
then it's good practice to add this check at top of routine.

HTH,

Sam
On Fri, 7 Jan 2005 11:43:26 -0500, " Just Me" <gr****@a-znet.com>
wrote:
I've seen this in example code:

Private Sub Studio_Closing(ByVal sender A..snip.. Handles MyBase.Closing

If e.Cancel Then Exit Sub

...snip...

It would make sense if Windows keeps doing Closing events even after it
receives an e.Cancel=true.

Is that the case?

Does the If make sense?

Can anyone shed some light on this?

Thanks for helpful comments

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
4
by: Deano | last post by:
Alot of my forms are bound. I would like to offer a Cancel option so that they can make as many changes as they like and still Cancel out without making any changes. I have one idea of how to...
6
by: Carl | last post by:
Hi you al I am new to this stuff and I found this code to close a form in the help files and I do not understand it or where its goe ' Calls this method from the InitializeComponent() method of...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
3
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it...
2
by: Bob | last post by:
In a winform with a datagridview using cellvalidating event but also have a save button that is located on a tablebindignnavigator. The behaviour I observe is that if the cellvalidating issues a...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
6
by: MLH | last post by:
I have a form, frmUSPSReturnReceipts, with a control named NotExpectingGreenTickets. The control's Exit event procedure follows: Private Sub NotExpectingGreenTickets_Exit(Cancel As Integer) If...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.