ByVal and Visual Studio 2010 SP1
-
Monday, February 14, 2011 5:31 AM
After installing VS 2010 SP1 I noticed that ByVal keyword doesn't automatically appear after declaring Function or Sub parameters. Is it new feature or bug?
For instance, if I wrote
Function GetValue(sName as String) As Double
and then pressed ENTER, the VB Editor automatically inserted ByVal before "sName":
Function GetValue(ByVal sName as String) As Double End Function
There is no knowle
Answers
-
Monday, February 14, 2011 7:19 AM
It is a change - as byval as default and therefore the pretty lister has been modified to avoid it inserting byval into your source.
- Proposed As Answer by spottyMicrosoft Employee Monday, February 14, 2011 7:20 AM
- Marked As Answer by Motaro Monday, February 14, 2011 8:33 AM
All Replies
-
Monday, February 14, 2011 7:19 AM
It is a change - as byval as default and therefore the pretty lister has been modified to avoid it inserting byval into your source.
- Proposed As Answer by spottyMicrosoft Employee Monday, February 14, 2011 7:20 AM
- Marked As Answer by Motaro Monday, February 14, 2011 8:33 AM
-
Monday, February 14, 2011 8:36 AMAgree with ya! The code looks much cleaner without ByVal. :)
There is no knowledge that is not power. -
Monday, February 14, 2011 1:23 PMModerator
Ironic.
I don't have SP1 (Is it official, yet?) but it's interesting how all these features that have been added over the years to the 'toy' language Visual Basic, are now being removed. I'm pretty certain that one of the versions of VB did not have the ByVal qualifier (VB 3, 4, or 5?), or it was optional.
Stephen J Whiteley -
Monday, February 14, 2011 3:46 PM
In VB classic it was Byref as default and optional.
I think when it was switch to .NET it became ByVal as default and therefore it was probably more important to highlight this distinction. After 5 different version of VB.NET this is probably not a source of confusion any more.
Removal of the Byval in VB.NET source code doesnt change any behavior as such - it just become implied by default.
I see a lot more features being added to the language as well as new syntax with removal of old items which may be a little obsolete with current programming practice. -
Tuesday, April 05, 2011 12:29 AM
I think it's better without ByVal keyword. In C#, this keyword is not automatically added when you add parameter. I think it's a decision with the Visual Basic team to be more close to the c# rules.
In a couple of years, visual basic will be a curly brace language and after that, it will die. :D