Byval e as CancelEventsArgs

B

Bob Day

Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArgs as an argument, and then the first line of code e.cancel =
false.

What is 'e' used for? How is it generated?

Thanks
Bob


Private Sub FormB_During_Closing(ByVal sender As System.Object, ByVal e As
CancelEventArgs) Handles MyBase.Closing

' Purpose: This event executes automatically when a form is closing (i.e.
when they choose File, Exit to execute form.close). It will first close all
Trunk Threads, and then all NON-trunk threads. See each of those methods for
more documentaion.

'don't cancel exit

e.Cancel = False

' code to process closing

end sub
 
A

Armin Zingler

Bob Day said:
Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval
e as CancelEventsArgs as an argument, and then the first line of code
e.cancel = false.

What is 'e' used for?

It is used for passing an object into the procedure. See also the docs on
the Closing event.
How is it generated?

It is generated in System.Windows.Forms.Form.OnClosing before it is passed
as the argument to the event that is also raised in OnClosing.
 
H

Herfried K. Wagner [MVP]

* "Bob Day said:
The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArgs as an argument, and then the first line of code e.cancel =
false.

What is 'e' used for? How is it generated?

It's generated (better: instantiated) by Windows Forms, which is part of
the .NET Framework. For more information on that, have a look at the
documentation for the 'CancelEventArgs' class. Just place the caret of
the IDE's text editor on the 'CancelEventArgs' and press the F1 key.
 
B

Bob Day

Very helpful, thanks.

On a minor note, it would be handy if in some future versions you allowed
working URL links in code comments, such as below. I often put URLs into
comments when I am doing something based on them, but they are nothing but
text (which can be cut and pasted to IE). You might pass it along to the
developers.

Private Sub FormB_During_Closing(ByVal sender As System.Object, ByVal e As
CancelEventArgs) Handles MyBase.Closing

' Purpose: This event executes automatically when a form is closing (i.e.
when they choose File, Exit to execute form.close). It will first close all
Trunk Threads, and then all NON-trunk threads. See each of those methods for
more documentaion.

'don't cancel exit. You can use E.Cancel to determine if this form should be
closed or not. For example, you could have a class wide Boolean "Closing_OK"
is true, set cancel to false, if "Closing_OK is false, set e.cancel to true.
Could be handy. However, we are confirming it is ok to close before we ever
get here. A good URL for explaination with sample code of ByVal e As
CancelEventArgs is
http://msdn.microsoft.com/library/d...emcomponentmodelcanceleventargsclasstopic.asp .

e.Cancel = False



Bob Day
 
P

Peter Huang

Hi Bob,

Thanks for your quickly reply and knowledge sharing.

Also about the URL in Comment, I think you may try to hold CTRL key and
click on the URL, which will open the a tab page in the IDE to navigate to
the URL. Is that what do you mean?


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bob Day

Yes, I am talking about clicking on a URL link in a coment in code (ie: '
this is a comment ) in VS 2003 VB.NET and it going to that URL. There is
currently no way to do it. Holding CTRL does nothing.

Thanks!
Bob Day
 
P

Peter Huang

Hi Bob,

Thanks for your quickly reply!

That is somewhat strange.
Have you tried the URL according to the format below?
'http://www.google.com
If you write the URL as below the function will not work.
'www.google.com

If I point the mouse cursor on the comment 'http://www.google.com and hold
the CTRL, the mouse cursor will become a hand.

You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Bob Day

Yes, that did the trick, adding http:// I also notice that if it is a long
URL and wraps to the next line, then it doesn't work. But you are correct
below.

Thanks!

Bob Day
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top