Are sub-routines parameters called by reference or called by value?

T

Thomas Lebrecht

When I call a sub-routine in a VBscript and I want to pass
two System.Collections.ArrayList objects
are these objects then passed by value or by reference?

In other words: are possible modifications (done in the subroutine) visible
OUTSIDE the subroutine or not?

Example:

Set arr1 = CreateObject("System.Collections.ArrayList")
Set arr2 = CreateObject("System.Collections.ArrayList")
.....<fill arr1 and arr2>...
.....

call mycalc

....

sub mycalc parm1 parm2
...
parm1.removeAt 1
...
end sub

Thomas
 
A

Armin Zingler

Thomas Lebrecht said:
When I call a sub-routine in a VBscript and I want to pass
two System.Collections.ArrayList objects
are these objects then passed by value or by reference?


Is there a reason why VBscript questions are also sent to the VB.Net group
lately?

In VB.Net, without specifying ByVal or ByRef, ByVal is the default. See
"Passing Mechanism" under the "Rules" headline:
http://msdn.microsoft.com/en-us/library/cbs7z96t.aspx


Armin
 
A

Alex K. Angelopoulos

Because the poster is often confused about which group is appropriate for
posting a particular question, usually (as in this case) due to some
confusion about the distinction between the .NET runtime and the language
used to access it.

For anyone who bothers to read this, if you're using a .NET from
VBScript/Jscript or any other Active Scripting language, posting to a .NET
language group isn't likely to net you any useful help; you're not using a
..NET language. It might be helpful to post in a core .NET group if it
appears that the issue might be confusion about how the component behaves,
but for a language issue - like the ByRef vs. ByVal behavior of VBScript -
it's best to post to the VBScript language group.
 

Ask a Question

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.

Ask a Question

Top