473,659 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Byval e as CancelEventsArg s

Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArg s 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_Cl osing(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 1736
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 CancelEventsArg s 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****@TouchTa lk.net> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArg s 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_Cl osing(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****@TouchTa lk.net> schrieb
Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval
e as CancelEventsArg s 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.OnCl osing before it is passed
as the argument to the event that is also raised in OnClosing.
Private Sub FormB_During_Cl osing(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****@TouchTa lk.net> scripsit:
The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArg s 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 'CancelEventArg s' class. Just place the caret of
the IDE's text editor on the 'CancelEventArg s' 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_Cl osing(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****@TouchTa lk.net> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Using VS2003, VB.NET, MSDE...

The code below is from a demo program. I don't under stand the Byval e as
CancelEventsArg s 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_Cl osing(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.m icrosoft.com> wrote in message
news:C1******** ******@cpmsftng xa07.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.m icrosoft.com> wrote in message
news:cI******** ******@cpmsftng xa07.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 points to something and changes it. The default for simple data types is ByVal and for objects, it's ByRef. Am I correct so far? If so, I still don't have a clue as
3
1640
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, adFldMayBeNull x.Open x.addnew "custtype", 34
3
1895
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 button01_click(ByVal sender As Object, ByVal e As System.EventArgs) I dont understand any of that part. ByVal? sender? e? System.EventArgs? Do you know of any good references explaining what this stuff is? I'm sure it's different for each routine, and I
7
5498
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
1784
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 actual variable that has been passed over, even though with ByVal this should not happen. Has anybody else discovered this or am I doing completely wrong /
14
1527
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 something? Regards /Niklas Public Class Main Shared Sub Main() Dim testPropObj As New MyPropertObject testPropObj.MyInt = 1
4
2465
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, as I expected. I haven't seen this behavior explained precisely in the .net world yet, so I wanted to check and make sure I've got it right. I apologize that this is a bit long. I've tried to keep it concise. There are code fragments here, but...
2
10265
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 application. The sub loadValueByVal takes the argument by value so after returning to calling method, the object should be unchanged but it is not Public Class ITest Private MyName As String Public TestId As String Public Sub New()
11
8116
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
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 we have to send another system

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.