From: "Eric Lippert (Microsoft Scripting Dev)" Subject: Re: ByRef not working in WSH/VBS Date: 1999/01/29 Message-ID: #1/1 References: <36a77afb.5046977@m1> <78pcq0$16l$1@platane.wanadoo.fr> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2012.2900 X-MSMail-Priority: Normal Newsgroups: microsoft.public.scripting.wsh Good point, I didn't cover what happens when you use the Call keyword -- OK, let's sum up with a code sample: Sub Bar( x ) End Sub Sub Baz( a, b ) End Sub Function Foo( y ) End Function z = 123 n = Foo(z) ' legal, passes z by reference n = Foo((z)) ' legal, passes z by reference 'n = Foo z ' illegal, parens required Foo z ' legal, passes z by reference Foo(z) ' legal, passes z by value 'Call Foo z ' illegal, parens required Call Foo(z) ' legal, passes z by reference Call Foo((z)) ' legal, passes z by value 'n = Bar(z) ' illegal, bar is not a function Bar z ' legal, passes z by reference Bar(z) ' legal, passes z by value Call Bar(z) ' legal, passes z by reference Call Bar((z)) ' legal, passes z by value Baz z, z ' legal, passes z by reference Baz (z), (z) ' legal, passes z by reference 'Baz(z,z) ' illegal, can't use parens Call Baz(z, z) ' legal, passes z by reference Call Baz((z), (z)) ' legal, passes z by value 'Call Baz z, z ' illegal, parens required This is what we in the programming language business call "a big mess". Unfortunately, we're stuck with it for backwards-compatibility reasons. Eric Theudrid wrote in message news:78pcq0$16l$1@platane.wanadoo.fr... > > Eric Lippert (Microsoft Scripting Dev) a écrit dans le message ... > |Hi there, > | > |This is NOT a bug -- this is by design. (Not very good design, in my > |opinion, but by design.) > | > |VBScript is compatible with VB, and VB has worked like this for many years > |now. If you have a VB sub that takes a byref argument and you enclose the > |argument in parentheses, the argument is always passed by value. VBScript > |works exactly the same way. > | > |Eric > > > Only if you forget the keyword "call"... > >