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

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Ruediger Roesler" <administrator@xxxxxxxxxxxxxxxxxx> wrote in message
news:49cabe3b$0$32665$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Richard Mueller [MVP] <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> typed:

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

In VBScript if the argument is a variable, array, or array element,
it is passed "by reference", unless you specify ByVal. If the
argument is an expression it is passed "by value". This is an
instance where the behaviour of VBScript is different from VB
(classic). I try to always specify ByVal or ByRef to avoid confusion.

Now we are so clever as like before, after all here have made known
their different opinions. If somebody has by chance a source for what
happens by the parametre handling with functions? Besides, also I could
observe already very much different behaviour of the Windows-Script-Host
interpreter. I would be very glad with a solution from reliable source.

The explanation advanced by you corresponds, at least, to my experiences
in the earliest. TIA

--
?R


This link from "Microsoft Windows 2000 Scripting Guide" explains (near the
bottom of the page):

http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_zuue.mspx

I also referred to "Windows 2000 Windows Script Host" by Tim Hill before my
original reply.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Are sub-routines parameters called by reference or called by value?
    ... OUTSIDE the subroutine or not? ... sub mycalc parm1 parm2 ... it is passed "by reference", ... I would be very glad with a solution from reliable source. ...
    (microsoft.public.scripting.vbscript)
  • Nonsense dialog box of "Sub or Function not defined"
    ... then based on the checked boxes on the ... I will be adding at least may be 15-18 more subroutine. ... .InsertBefore PLName ... Word 2007 Developer Reference> Visual Basic for Applications Language ...
    (microsoft.public.word.vba.general)
  • RE: Object library feature not supported....
    ... I had to uncheck the WindowsMediaPlayer Reference, save, then re-check the ... It appears that the object model loaded as a result of the software ... > Windows Media Player ...
    (microsoft.public.excel.programming)
  • Re: 16 Bit Windows Subsystem Error S32EVNT1.DLL
    ... Bit Windows Subsystem error, as the Symantec KB provides the same solution ... the reference to Symantec appears in the error ... "16 Bit MS-DOS Subsystem" Error Message When You Install a Program ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: c:windowsinet20001winlogon.exe (unable to find)
    ... Open the Registry Editor... ... How to backup the Windows XP Registry ... Or get Startup Control Panel and use it to disable any reference to ...
    (microsoft.public.windowsxp.help_and_support)