When you will read the VB sections of the book some students who took VB might be surprised by the functions written without ByVal parameter as well as the way they behave. This can be explained by differences between how parameter passing worked in VB 6 and how it works in VB.NET (that you will be using in this course).
In Visual Basic 6.0, if you do not specify ByVal or ByRef for a procedure argument, the passing mechanism defaults to ByRef. This allows the variable passed into the procedure to be modified in the calling program.
When you declare a procedure in Visual Basic .NET, the passing mechanism defaults to ByVal for every argument. This protects arguments against modification. Although ByVal is the default mechanism, specifying it explicitly for every argument removes uncertainty and makes your code easier to read.
No comments:
Post a Comment