473,224 Members | 1,657 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,224 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 1519

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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.