Can VBScript pass parameters by reference?
For example
function DDD (str)
Str=str & "12345"
End Function
Abc= "54321"
Want to turn ABC into "5432112345" by DDD (ABC)
How to change it?
Answer:
<script language=vbs> function ddd (str) STR=STR & "12345" End Function abc= "54321" DDD ABC msgbox ABC &L T;/script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
There's no place to change.
In fact, the default method of passing parameters in VBScript is ByRef, if you want to pass the value, write
Function DDD (ByVal str)
...
However, when calling a function defined by the VBS in JS, the parameter is passed by value, indicating that byref is not used
If you want to change the value, you can wrap it up with an object, such as
<script language=vbs> Sub Chgarg (a) a.x=100 a.y=100 End Sub </script> <script LANGUAGE=JSCRIPT&G T var t={x:0,y:0,show:function () {alert ("this.x=" +this.x+ ", this.y=" +this.y)} t.show (); Chgarg (t); T.show (); </script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]