Wrox Programmer Forums
|
BOOK: Professional VB.NET, 2nd Edition or 2003
This is the forum to discuss the Wrox book Professional VB.NET, 2nd Edition by Fred Barwell, Richard Case, Bill Forgey, Billy Hollis, Tim McCarthy, Jonathan Pinnock, Richard Blair, Jonathan Crossland, Whitney Hankison, Rockford Lhotka, Jan D. Narkiewicz, Rama Ramachandran, Matthew Reynolds, John Roth, Bill Sheldon, Bill Sempf; ISBN: 9780764544002
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional VB.NET, 2nd Edition or 2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2003, 12:36 PM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ByVal vs. ByRef: Error in book

On page 99 (I think) there is a discussion that the default for parameters is ByVal in VB.Net vs. ByRef in VB6. Then the text goes on to state that this is much better because ByRef is higher overhead because the data must be copied to the sub or function and then copied back once the sub or function completes.

I hope that this is an incorrect description of the way ByRef parameters are passed. I believe that the address of the ByRef variable(s) are copied at the call to the subprogram. Then the subprogram uses/modifies the variable that is in one, and only location, in memory. At the exit from the subprogram there is no copying back of the ByRef parameters.

If my understanding of subprogram calls is correct, then the book is wrong. ByVal parameters have higher overhead but are much safer because they remove the possibility of unintended consequences of data modification for the calling program.

Any feedback would be appreciated.

Greg
[email protected]
 
Old August 20th, 2003, 09:41 PM
Wrox Author
 
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Greg,
The answer to your question is that it depends on which version of .NET you are using. The book was written to version 1.0 and in version 1.0 ByRef parameters were not handled as you expect which is why that specific item was called out, as it relates to the material that was available and which the book covered, the book is correct. (It is also why Microsoft changed the default for parameters which hopefully someday they will change back)

However, If like most developers you have migrated to version 1.1 of .NET then you will find that .NET has been updated and works much closer to what you expect. When/if an edition that reflects .NET version 1.1 is released this would be one of the items to be updated.
Bill
 
Old November 26th, 2003, 08:00 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 
Quote:
quote:in version 1.0 ByRef parameters were not handled as you expect which is why that specific item was called out, as it relates to the material that was available and which the book covered, the book is correct. (It is also why Microsoft changed the default for parameters which hopefully someday they will change back)
Quote:

However, If like most developers you have migrated to version 1.1 of .NET then you will find that .NET has been updated and works much closer to what you expect. When/if an edition that reflects .NET version 1.1 is released this would be one of the items to be updated.
Any updates / confirmation on this? 1.1 has been out awhile and I can't find any confirmation on google...

 
Old May 28th, 2004, 12:12 PM
Wrox Author
 
Join Date: Aug 2003
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
Default

http://msdn.microsoft.com/library/de...pec7_1_6_2.asp
 
Old July 2nd, 2004, 10:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for posting the link BillS.

XUMUSKIEFAN
Wrox Moderator





Similar Threads
Thread Thread Starter Forum Replies Last Post
ByRef Argument! Apocolypse2005 Beginning VB 6 11 August 9th, 2007 02:21 PM
Passing ADO Recordset ByVal robzyc Access VBA 2 April 23rd, 2007 09:07 AM
ByRef property rolandatem VB.NET 2002/2003 Basics 1 October 8th, 2005 08:42 AM
byRef ? g2000 Classic ASP Basics 0 August 18th, 2005 09:37 AM
ByRef and ByVal kgs51 Beginning VB 6 2 November 2nd, 2004 08:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.