C
Chris Hohmann
Chris Hohmann said:In test 1.1 the a _reference_ to the local y variable in test0 is being
passed to the test1 function.
That should read:
In test 1.1 a _reference_ to the ...
Chris Hohmann said:In test 1.1 the a _reference_ to the local y variable in test0 is being
passed to the test1 function.
Roland Hall said:in message
: : > A local variable
: > will also change if passed byRef to another sub/function?
:
: Yes.
:
: <%
: Option Explicit
: Function Foo(parameter_by_ref)
: Dim return_value, local_variable
: local_variable = parameter_by_ref
: return_value = Bar(local_variable)
: Foo = local_variable
: End Function
:
: Function Bar(parameter_by_ref)
: parameter_by_ref = parameter_by_ref + 1
: Bar = "Hello World"
: End Function
:
: Response.Write Foo(4)
: %>
Also helpful... thanks.
This was very interesting to see:
Option Explicit
Function Foo(parameter_by_ref)
Dim return_value, local_variable
local_variable = parameter_by_ref
Bar(local_variable)
Foo = local_variable
End Function
sub Bar(parameter_by_ref)
parameter_by_ref = parameter_by_ref + 1
End sub
wscript.echo Foo(4)
Result: 4
Option Explicit
Function Foo(parameter_by_ref)
Dim return_value, local_variable
local_variable = parameter_by_ref
Bar local_variable
Foo = local_variable
End Function
sub Bar(parameter_by_ref)
parameter_by_ref = parameter_by_ref + 1
End sub
wscript.echo Foo(4)
Result: 5
Roland Hall said:Great example. Very helpful. Thanks.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.