Closed ghost closed 3 years ago
I don't know about VBA. However, this documentation is for VB.NET, not VBA. The information is correct for VB.NET.
Thank you, Youssef. I appreciate your response, and that makes sense that it could be different in .NET vs VBA. I found this page when searching “Excel VBA is ByRef or ByVal defaulthttps://www.google.com/search?q=excel+vba+is+byval+or+byref+default” and also “ByVal VBAhttps://www.google.com/search?q=byval+vba,” so I assumed that the reference pertained to VBA without even checking. Thank you for clarifying that for me.
Ryan Parker
From: Youssef Victormailto:notifications@github.com Sent: Saturday, January 30, 2021 10:47 AM To: dotnet/docsmailto:docs@noreply.github.com Cc: Ryan Parkermailto:Ryan.Parker2@Outlook.com; Authormailto:author@noreply.github.com Subject: Re: [dotnet/docs] ByRef is the default, not ByVal, when using Sub statements with parameters (#22566)
I don't know about VBA. However, this documentation is for VB.NET, not VBA. The information is correct for VB.NET.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/docs/issues/22566#issuecomment-770250268, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQTOKID66KKNYQGHR6VTXALS4RAZTANCNFSM4WZL2WZA.
closing per conversation.
[Enter feedback here]
Hi Microsoft Docs team, I discovered an inaccuracy in the documentation article about
ByVal
, found at: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/modifiers/byval.The documentation states that "If no modifier is specified, ByVal is the default. ... Because it is the default, you do not have to explicitly specify the ByVal keyword in method signatures. It tends to produce noisy code and often leads to the non-default ByRef keyword being overlooked."
However, as my Excel VBA code below demonstrates,
ByRef
is the default value, notByVal
, when using parameters withSub
statements.Also, here's another source that confirms that ByRef is the default: https://bettersolutions.com/vba/macros/byval-or-byref.htm
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.