473,503 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Byval e as CancelEventsArgs

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
Nov 20 '05 #1
8 1729
Hi,
In general a event procedure you have two arguments sender which
the object creating the event and e which is the event arguments. In this
case you are getting a CancelEventsArgs class. It has a property cancel
which allows you to cancel the event. So e.cancel = false means go ahead
and process the event.

http://msdn.microsoft.com/library/de...classtopic.asp

Ken
---------------
"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #2
"Bob Day" <Bo****@TouchTalk.net> schrieb
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.
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

--
Armin

Nov 20 '05 #3
* "Bob Day" <Bo****@TouchTalk.net> scripsit:
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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
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/de...classtopic.asp .

e.Cancel = False

Bob Day

"Bob Day" <Bo****@TouchTalk.net> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #5
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.

Nov 20 '05 #6
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

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:C1**************@cpmsftngxa07.phx.gbl...
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.

Nov 20 '05 #7
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.

Nov 20 '05 #8
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

"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:cI**************@cpmsftngxa07.phx.gbl...
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.

Nov 20 '05 #9

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

Similar topics

8
383
by: Sandy | last post by:
Hello! Help!!!! I have ten zillion books that attempt to describe the difference between ByVal and ByRef and none of them are clear to me. I have gathered that ByVal makes a copy and ByRef...
3
1626
by: WG | last post by:
Here is an ASP code sample in VBScript: <% Dim x Set x = server.CreateObject("ADODB.RECORDSET") x.CursorType = 1 x.CursorLocation = 3 x.Fields.Append "custtype", adVarNumeric, 80,...
3
1891
by: Maurice Walmsley | last post by:
I'll avoid tell you how lame I am and get straight to the question... I need a good expanation to the "ByVal sender As Object, ByVal e As System.EventArgs" part of; Public Sub...
7
5491
by: Hei | last post by:
Hi, i know the difference of ByRef and ByVal, in case if use byref or byval don't affect the result which one should prefer? (less memory use, better performance ....issue) thx
16
1766
by: Richard | last post by:
Hi, I am passing a structure to a subroutine where the passed parameter has been declared as ByVal. However, changes made to the passed variable inside the subroutine flow through to the...
14
1508
by: Niklas | last post by:
Hi What I have learned is that a variable is just a reference when dealing with Objects. Are you supposed to use ByVal or ByRef in functions? They produce the same result or have I missed...
4
2443
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
2
10258
by: Witold Iwaniec via .NET 247 | last post by:
It seems that when you pass an object to a function it is always passed by reference even if it is explicitly declared ByVal. Is it the behavior of VB.Net? Here is sample code from sample Asp.Net...
11
8094
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
0
7204
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
7091
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
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
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,...
1
5018
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...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.